yami007 Posted November 27, 2009 Share Posted November 27, 2009 When I click the link to add the file values disappear, what can i do to prevent this?? this is my code so far <html> <head> <title>Add multiple uploads</title> <script language="javascript"> <!-- var clicks = 1; function clicked() { document.getElementById('clicked').value = ++clicks; } function writeToDoc() { text = 'File '+clicks+' <input type="file" size="70" name="file_'+clicks+'" /><br/>'; document.getElementById('1').innerHTML = document.getElementById(1).innerHTML += text; } //--> </script> </head> <body> <a href="javascript:writeToDoc()" onclick="clicked()">Add</a> <form name="upload"> <div id="1"> File 1 <input type="file" size="70" name="file_1" /><br/> </div> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/183126-problem-with-multiple-files-upload/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 27, 2009 Share Posted November 27, 2009 Because the type="file" value can only be set by the browser's file select dialog box, you cannot use standard methods of adding fields by rewriting all the values. You must insert/add fields. Here is a link to script that shows how to do this - http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/ Link to comment https://forums.phpfreaks.com/topic/183126-problem-with-multiple-files-upload/#findComment-966479 Share on other sites More sharing options...
yami007 Posted November 27, 2009 Author Share Posted November 27, 2009 Because the type="file" value can only be set by the browser's file select dialog box, you cannot use standard methods of adding fields by rewriting all the values. You must insert/add fields. Here is a link to script that shows how to do this - http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/ thanks i read that article, it's cool. but I wonder if there's a way to keep the values in the file, i saw this on a page. and i just want to do it as simple as my code!! Link to comment https://forums.phpfreaks.com/topic/183126-problem-with-multiple-files-upload/#findComment-966514 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.