We help IT Professionals succeed at work.

<input type=file name=file>

augblay
augblay asked
on
can i dynamicaly set the value of this html control and submit the form, here is an example of what i want to do:

<form  action="upload.asp" method="post"
     ENCTYPE="multipart/form-data"  name="aa">
 <input type=file name=file>
 <input type=file name=file2>
 <input type=button value=submit onclick='grabfiles()'>
</form>

<script>
     function grabfiles()
     {
          window.document.aa.file.value="c:\logfile.txt";
          window.document.aa.file2.value="c:\stats.txt";
     window.document.aa.submit();
         
         
     }
</script>
Comment
Watch Question

try this

<form  action="upload.asp" method="post"
    ENCTYPE="multipart/form-data"  name="aa">
<input type=file name=file1>
<input type=file name=file2>
<input type=button value=submit onclick='grabfiles()'>
</form>

<script>
    function grabfiles()
    {
         document.all.item("file1").value="c:\logfile.txt";
         document.all.item("file2").value="c:\stats.txt";
         document.aa.submit();
         
         
    }
</script>

Author

Commented:
nope, did not work
Top Expert 2013
Commented:
You cannot set a value for input type file.  It would be a security
hole that would allow sites to steal files from a user computer.

The user has to set the value.
Cd&

Author

Commented:
thanks for your input
Top Expert 2013

Commented:
Thanks for the A. :^)

Cd&

Explore More ContentExplore courses, solutions, and other research materials related to this topic.