The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
Repopulating $_FILES upon failed validation - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: Repopulating $_FILES upon failed validation (/showthread.php?tid=608) |
Repopulating $_FILES upon failed validation - Jaace - Mar 25th, 2010 I've been reading up on input type file around the net and it seems that it's a security issue, and thus not possible, to repopulate the input type file value with anything at any time. But I have a problem...in my form, I'm doing just server-side validation right now and when something fails, my uploads go away. I checked and saw that the $_FILES array was getting sent back to the form, so I thought I could use that to repopulate the files that the user already selected...but no luck. Is there any way I can accomplish repopulating uploaded file fields when a form doesn't validate? It's really a pain for a user to have to go through choosing all of their files again just because an email address was mis-spelled, you know? Thanks for the help! RE: Repopulating $_FILES upon failed validation - Ben - Mar 28th, 2010 Hi Jaace, Unfortunately not... at least, not without a lot of customization. Form submissions that contain a file are sort of "one shot deals". From a server-side perspective, you have access to that uploaded file at that one time only. You can't access the uploaded file on the subsequent form submit - this is forbidden, mostly for security reasons. But this is very reasonable request. I've logged it as a bug, here: http://bugs.formtools.org/index.php?cmd=view&id=211 To be perfectly honest, I'm not sure how to elegantly solve it. I think it may need a custom function added. Blurgh, very messy. Sorry, Jaace. I'll have to investigate this in an upcoming version of the API. - Ben RE: Repopulating $_FILES upon failed validation - Jaace - Mar 28th, 2010 No worries Ben! Thanks for considering it though :-). If I come up with anything myself I'll be sure to send it over your way. Cheers! |