Jump to content

keeping file in form to save after correction


asmith

Recommended Posts

I'm trying to get an image from the user in a form.

 

If the form has error like he hasn't type his email, the form is viewed again but his last correct entries is still there, like :

 

<input name=email value=$_POST />

 

how can i keep the image he had uploaded ? what that will be for the "<input type=file" ?

 

 

When the form processing code ends execution, the temporary uploaded file is automatically deleted by php. Your code would need to save the uploaded file somewhere (session, file...). The type="file" value is read only (and if you could put the file name in it, you would be wasting your bandwidth because the same file would be uploaded each time the form gets submitted.)

So ... I don't want to ask the user to upload again, How to store it in session?

 

or if i save the file somewhere and user leave my form, How to find it out?

 

I mean I can think of someways to do it, like I store a variable in a session, if the form didn't submit, then checking that variable of the session, so  i delete the file, but is that the standard way?

 

What most people do in these cases?

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.