my code stock.com

Upload Javascript File

Snippet options

Download: Download snippet as uploaderjs.js.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

function addBrowseFile(counter){
	document.getElementById("divdynamicInput").innerHTML = '';
	for(var i=0;i<counter;i++){
	  var newdiv = document.createElement('div');
	  newdiv.innerHTML = "Upload File " + (i+1) + ' : <input type="file" id="file_' + i + '" name="file_' + i + '"><span id="file_status_' + i + '"></span>';
	  document.getElementById('divdynamicInput').appendChild(newdiv);
	}
}

function upload()
{
	var counter = document.getElementById("no_files").value;
	for(var i=0;i<counter;i++){
		var file_status = 'file_status_' + i;
		document.getElementById(file_status).innerHTML = ' In Progress....';

		var xmlhttp;
		if (window.XMLHttpRequest)
		{
			xmlhttp=new XMLHttpRequest();
		}
		else
		{
			// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			  {
				document.getElementById(file_status).innerHTML = xmlhttp.responseText;
			  }
		}
		xmlhttp.open("POST","upload.php",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send("file=file_" + i);
	}
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.