473,385 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
2 3444
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
Á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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lazyadmin | last post by:
I would like to use this code on my website to allow simple file uploads from clients. I would like to restrict the file types they can upload. Can this be done? Any help appreciated. Rod...
1
by: TK | last post by:
I have a file upload control to allow a user to select/upload a file to the server. They need to upload x number of files in one shot because they have to confirm that they are uploading x number...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
8
by: Todd Acheson | last post by:
I'm having a small problem with uploading files in ASP.NET. My html page for uploading has something similar to: <form id="Form1" method="post" enctype="multipart/form-data" runat="server">...
3
by: Pitcairnia | last post by:
The basic purpose of the site is for authenticated users to post event listings, which often include photographs. The user is faced with a page where they can insert all of the information about...
2
by: Sridhar | last post by:
Hi, I have a web form where it has a <input type=file id=file1> control. I have an Upload button to upload the file. WHen I click on browse and select one file, it is showing the full file path...
3
by: RAMohrmann | last post by:
Greetings, I am attempting to view all files in a directory and if those files have not been modified within the last couple days I will remove them. In order to do this I need to look at the...
17
by: Paul | last post by:
On my development computer, I have virtual named host set up, like www.site1.lab. When I upload those to my web site for customer review under mywebsite.com/clients/site1/ it throws some of the...
10
by: Mike.Duffy | last post by:
What is the default directory in the client file system that is used for file urls? From performing a few experiments, it is clear that an unqualified reference from another file url is always...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.