CodeIgniter Forums
Uploading files and auto populating the upload form input when an error occurs - HOW? - 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: Uploading files and auto populating the upload form input when an error occurs - HOW? (/showthread.php?tid=6140)



Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 02-15-2008

[eluser]Jay Callicott[/eluser]
OK I have an issue that I've had a long time where I have a regular form and I have some attachments at the bottom. I make it so that the upload is not tried unless the form validation is successful. The problem is that any sort of error on the page, be it from the regular form or attachments makes the upload form input box blank which is really irritating to the user.

When I examine the FILE array I don't see the local path to populate the input box. Does anyone have a good way of handling this?


Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 03-06-2008

[eluser]Jay Callicott[/eluser]
anybody have some advice on this?


Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 03-06-2008

[eluser]Avatar[/eluser]
sorry this is not enough info, can I see code?


Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 03-06-2008

[eluser]Doosje[/eluser]
I think you need todo it with some ajax ...

Or present them another screen where they can upload


Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 03-11-2008

[eluser]Jay Callicott[/eluser]
This is really more a PHP issue, I can't really find out where PHP stores the local file path. I know it does bc if the CI upload class will get that information. I think the problem is that I don't upload the file unless the other error validation succeeds. I suppose I could capture the text with javascript and submit it as a hidden variable but I don't think I've had luck prefilling file input boxes before. I will do some tests.


Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 03-11-2008

[eluser]adamp1[/eluser]
I didn't know it did send the information. Why does the upload class get that information? All that does is move the file from a tmp location to the place you specify.

From what I know the local path is not sent, only the file data.


Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 03-12-2008

[eluser]Jay Callicott[/eluser]
Hmm I suppose the issue is a security issue. You can't pre-fill an upload field, the browser doesn't let you. think if you could make the browser upload any file. So I guess the only thing I could do is still do the upload even if the other validation doesn't work.


Uploading files and auto populating the upload form input when an error occurs - HOW? - El Forum - 03-12-2008

[eluser]Pygon[/eluser]
Alternatively, you could have javascript copy the local path into a hidden field when it loses focus or on submit, although I don't know if you can set a default for the file upload form field.