Jump to content

problem with multiple files upload


yami007

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.