FileField empty after form validation

瀏覽次數:280 次
跳到第一則未讀訊息

josephi

未讀,
2010年8月23日 凌晨4:14:442010/8/23
收件者: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

未讀,
2010年8月23日 清晨6:14:192010/8/23
收件者: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/

回覆所有人
回覆作者
轉寄
0 則新訊息