FileField empty after form validation

280 views
Skip to first unread message

josephi

unread,
Aug 23, 2010, 4:14:44 AM8/23/10
to Django users
Hi, I have a suspicion that my problem might not be Django specific,
but I'm not entirely sure, and would appreciate any pointers to
information on the subject.

I have a Form with several fields, one of which is a FileField. This
field is required. If I fill in the FileField but the form doesn't
validate because of other field errors the FileField widget becomes
empty once the form is redisplayed after validation. This forces the
user to re-select their file.

Can anyone tell me the reason for this? Is there a workaround?

Thankyou

Joseph

Karen Tracey

unread,
Aug 23, 2010, 6:14:19 AM8/23/10
to django...@googlegroups.com
The reason is because typically browsers don't allow the web server to pre-fill a file input with a value. (Allowing this would enable malicious servers to easily trick naive users into uploading sensitive files.)

Karen
--
http://tracey.org/kmt/

Reply all
Reply to author
Forward
0 new messages