Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.