Solved

Populate a file input type on load.

Posted on 2004-03-22
6
2,165 Views
Last Modified: 2012-08-13
Hello, I have created a dynamic form where the user can add several files for upload. This form is a popup to the main form. When the user clicks submit on the popup form I do not upload the files straight away but rather I save the info in a hidden variable. When the user changes his mind and goes back to the file upload popup form again I would like to display on the file input fields the values he previously selected. However for some reason it does not seem to work. The way I create the dynamic form is the following:

//create a new input object--this is the actual textbox
obj=document.createElement("input");
                        
//give it a type
obj.type="file";
                        
// give it a size
obj.size="75";
                        
//give it an id
obj.id="file"+cnt;
                        
//add the object to the form
frm.appendChild(obj);

//create a new line break object (<br/>)
obj=document.createElement("br");
                        
//add the object to the form
frm.appendChild(obj);

When the popup appears I try append the previously input values but to no avail. The way I try to make it is the following:

obj.value=fileNamesArray[i];

where the fileNamesArray variable holds all the file names to be uploaded. I am sure there are filenames in the array since in the beginning of the for loop I have an alert box and it displays the file names correctly:

alert(fileNamesArray[i]);

Any help is more than welcome.
0
Comment
Question by:girionis
  • 3
  • 2
6 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 60 total points
ID: 10647477
Absolutely not possible.
If you were able to, you could fill it with
c:\documents and settings\private files\passwordlist

Michel
0
 
LVL 35

Author Comment

by:girionis
ID: 10647506
Hello mplungjan, thank you for your quick reply. Are you absolutely sure that it can't be done? This seems to work:

<input type="file" name="fileName" value="c:\documents and settings\private files\passwordlist"/>
0
 
LVL 17

Assisted Solution

by:mreuring
mreuring earned 40 total points
ID: 10647561
If that works it's scary as hell and I would like to know in which browser so that I can make sure to avoid it as the plague it is.
This is most certainly not something that ought to be possible and should be filed as a bug if it's allowed.
As Michel tried to point out you could fill it with a file that contains sensitive information and then post it to your server allowing you to get your hand son that info...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 35

Author Comment

by:girionis
ID: 10647585
It works on Opera 7.23 final for Linux. But you are right, it does not work under Netscape, Mozilla and IE. So it's a bug in Opera then. I will file a bug report.

I will accept the answers then since there is nothing I can do about it.
0
 
LVL 35

Author Comment

by:girionis
ID: 10647596
Thank you both :)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 10647666
You are welcome...

Michel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now