473,395 Members | 1,949 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,395 software developers and data experts.

Filename for Uploading

I have a form that asks the user to upload a file. I have a field on this
form and I want to re-populate this form if it do not pass a validation
function. All other fields let me set the VALUE. I understand that the
"file" input type is different.

How can I re-populate the file name in this type of field. I have tried the
following statement but it does not work ...

<input type="file" name="datafile2" value="<c:out value="${param.datafile2}"
/>" size="40">

Any ideas?


Jul 23 '05 #1
3 1176
In article <41**********@127.0.0.1>, ti*********@brewersmarine.com
says...
I have a form that asks the user to upload a file. I have a field on this
form and I want to re-populate this form if it do not pass a validation
function. All other fields let me set the VALUE. I understand that the
"file" input type is different.

How can I re-populate the file name in this type of field. I have tried the
following statement but it does not work ...

<input type="file" name="datafile2" value="<c:out value="${param.datafile2}"
/>" size="40">

Any ideas?


Although the HTML spec. permits pre-population of the value field, most
browsers disallow this for security reasons.

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #2
"Hywel Jenkins" <hy**********@hotmail.com> wrote in message
news:MP************************@news.individual.ne t...
In article <41**********@127.0.0.1>, ti*********@brewersmarine.com
says...
I have a form that asks the user to upload a file. I have a field on
this
form and I want to re-populate this form if it do not pass a
validation
function. All other fields let me set the VALUE. I understand that
the
"file" input type is different.

How can I re-populate the file name in this type of field. I have
tried the
following statement but it does not work ...

<input type="file" name="datafile2" value="<c:out
value="${param.datafile2}"
/>" size="40">

Any ideas?


Although the HTML spec. permits pre-population of the value field,
most
browsers disallow this for security reasons.


Here is my suggestion:

< if (param.datafile2 contains a value) then >
Selected file: <span style="font-family:monospace;">="<c:out
value="${param.datafile2}" /></span> (copy/paste this into the following
input)
< end if >
File to be uploaded: <input type="file" name="datafile2" size="40">

This way, users don't have to browse for the file again, they can simply
copy/paste the value they see into the input. It's more cumbersome than
populating the <input ... value="...">, but that's the price you pay for
using a browser as your UI.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
Since it's not possible to repopulate a file input field I wonder
consider dividing your form into 2 pages. The first page would take all
the user's details except the file and perform validation on that, and
the second page would just ask the user for the file.

Some nice side effects of this 2 step approach is that you are not even
bothering to receive files from user's who's data doesn't pass your
validation. And the other is that if the file uploaded takes 2 minutes
over a modem the user doesn't have to wait 2 minutes before finding out
their data was invalid.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kbrad | last post by:
I am uploading files to my webserver using an asp upload script and would like to add a timestamp just before they are saved to the server. This would mean that filename.txt on my server would be...
7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
1
by: Jan Idealny | last post by:
Hi, I want to make my uploading script resistent against malicious filenames. I want him to search for an inappropiate character in a given filename (stored in a variable) and then to print an...
5
by: Ariel Dolan | last post by:
Can I use HtmlInputFile to only get the selected file name but not actually upload the file? Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile...
0
by: Rob Maui | last post by:
I use the following code in an aspx file to read the file name which I am uploading from the client PC onto the server; Dim MyFileName As String Dim MyFileColl As HttpFileCollection =...
15
by: Larry Bud | last post by:
I rarely crosspost, but this affects both ASP and Javascript REALLY odd bug that I ran across in ASP 3.0. I have an input type of file, user clicks browse, then places his cursor in the...
4
by: Acrobatic | last post by:
I'm having troubles uploading an image and getting data from getimagesize(). When I upload a file with the name "20050914_loRes_XLH1.jpg", and do a getimagesize on it, it returns no info (null...
6
by: Reggie | last post by:
am trying to associate username with filename in a upload script. I get this error: Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/upload.php...
8
by: andyau | last post by:
I am uploading a file to the server and at the same time I want to place the file name in to a database. But for the the file to be effective I need to trim the path from the filename and leave...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.