Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
June 25, 2008, 4:08 pm
rate this thread
the value= attribute?
Here is the scenario:
A web form with some basic fields (name, address, etc.) plus a file
upload field. If the user forgets to fill in a required field (eg,
name), I show the form again, requesting them to fill in the required
field. We don't want to force them to enter everything again, so the
other fields have been pre-filled with their information (using the
value= attribute) -- however this does not work for the file upload.
I can identify the file name:
$file_reference = $_FILES['upload_pdf']['name'];
but this does not contain the full path reference. Also, I cannot put
this value into the form using the value= attribute -- it doesn't
Does anyone know how to make this work?
June 25, 2008, 4:17 pm
Re: File Upload - how do I get full path, or cache a reference?
Apart from security considerations and browsers implementations, it just
wouldn't make sense in your case. That way you would force the user to
upload the same file again.
You can save the file to a temporary location (typically with a random
name) and add a hidden field with the file name (path not necessary) and
a visible label with the original fila name. Use the first field to
recover the file when data is okay and the second one to let the user
know there file is okay. When you have everything, move the file to the
final location. Clean up the temp folder one in a while.
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com