Jump to content

holding an image value for upload


1internet

Recommended Posts

So if you have a form, that also has an image upload facility, but on submit there are some errors so the form doesn't submit, but holds all the values that were there before submission - how can you hold the image value.

i.e. do you have to always upload the image again? At least without the use of ajax.

Link to comment
https://forums.phpfreaks.com/topic/272814-holding-an-image-value-for-upload/
Share on other sites

You'd have to store the file somewhere temporarily and include something in the form which indicates to use that file (unless the user wants to upload a different file). Of course if the file itself causes an error then you wouldn't want to bother with this.

Exactly. Your best bet is to save it to the temporary folder on your server, so it will be cleared out periodically. Then you will need to save the location of that file somewhere that the user cannot see (for security reasons), so a SESSION variable is probably best. Then you can reference this on the second (or third or whatever) submission attempt when there are no errors.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.