• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Uploading files and auto populating the upload form input when an error occurs - HOW?

#1
[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?

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

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

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

Or present them another screen where they can upload

#5
[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.

#6
[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.

#7
[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.

#8
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.