By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

File Upload - how do I get full path, or cache a reference?

P: n/a
Is it possible to store the full path of a file upload, and return it in
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
display anything.

Does anyone know how to make this work?
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
vol30w60 escribió:
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.
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
--
Jun 27 '08 #2

P: n/a
Álvaro G. Vicario wrote:
vol30w60 escribió:
>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.

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.
Thanks! This approach is better than what I was trying to do.
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.