I have a form the the user fills in the data for processing by php. Only thing is that this is one of two forms on the page. The first form collects data for an ad placement, and one of the input fields is for an image. Once all the data has been entered, using getElementById I pass the values entered to a second form. Well, that is working ok except on my file input field. Here is a simplified vesion of my code: <html> <head> <script type="text/javascript" language="javascript"> function whatever() { var boo = document.getElementById('foo').value. return boo; } </head> <body> <form action="page.php" method="post" enctype="multipart/form-data"> <input type="file" name="foo" id="foo" onchange="window.document.form2.inputname.value=whatever();"/> </form> <form action="page.php" method="post" name="form2" enctype="multipart/form-data"> <input type="file" name="inputname"/> <input type="submit" name="upload" value="UPLOAD"/> </form> </body> </html> Code (markup): Now, I realize that input type of file contains an array, but how can I get and pass that array using javascript? Thanks!
For security reasons it's not possible to write to file type inputs, and some browsers only allow the actual file name to be read from such inputs, not the path data.