Jump to content
Larry Ullman's Book Forums

Input Type File Sticky


Recommended Posts

I have read online that browser as a security issue block the input type file from being sticky, i tried to print back the value from $_FILES['upload']['name'] back into the value attribute of the input tag but it failed to work. Does anyone have any suggestions on what they would do in this complex situation?

Link to comment
Share on other sites

You cannot make a file input sticky, that is true. What I normally do in this situation is store the uploaded file data in a session (or elsewhere) and then indicate to the user that the file has already been uploaded. Then when the form is properly completed, you can do whatever with the previously uploaded file.

Link to comment
Share on other sites

Yeah, I have come across this requirement a few times. One option is to display the file name next to the upload button with a message asking them to reselect it. Its not the most user friendly approach but I think its better than doing nothing. If you find another solution, please post it.

 

The security precaution makes sense once you know it but if you don't inform your user, they might think there is a problem.

Link to comment
Share on other sites

Thanks guys. I am going to leave this part in my site as normal upload for now. But later recode this part in using Javascript, i will use your idea Larry Storing the upload information for the picture's uploaded in a session. I see ebay an other sites just using regular html buttons to handle this, once you click them the file select box opens up, where you can pick your pictures. Then you will see a jquery progress bar loader working and the picture will be loaded inside a div for your view, you can then load up other pictures or delete them as you please. Using a html button works out better as then we don't have to deal with this sticky upload button problem.

Link to comment
Share on other sites

 Share

×
×
  • Create New...