CodeIgniter Forums
How to restore file_upload value on error? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to restore file_upload value on error? (/showthread.php?tid=5151)



How to restore file_upload value on error? - El Forum - 01-08-2008

[eluser]James Spibey[/eluser]
Hi,

I'm trying to figure out the best way to retain the value of a file upload field between postbacks of a form. The problem I have is that the field isn't 'required' and so if they post a form and it fails validation, it isn't clear that they need to upload the file again.

Has anyone come across this?

Cheers

James


How to restore file_upload value on error? - El Forum - 01-08-2008

[eluser]xwero[/eluser]
you could check if a file was uploaded and on error you could highlight the file field to make sure people add the upload again.


How to restore file_upload value on error? - El Forum - 01-08-2008

[eluser]ejangi[/eluser]
spib, it's important to note that file upload fields don't have a value="" attribute, so you can't repopulate it. xwero's suggestion is spot on and probably the best way for you to keep users from getting too confused.


How to restore file_upload value on error? - El Forum - 01-09-2008

[eluser]James Spibey[/eluser]
Thanks guys. In the end I did pretty much as suggested but also added a banner at the top of the page explaing that they need to re-select the file to upload