Image uploads with Javascript

Discussion in 'JavaScript' started by forumposters, Feb 5, 2007.

  1. #1
    I need a script that upload many files as once - maybe with an "add more files" button that simply inserts more "browse boxes" and captions. I imagine Javascript is the best way to do this, but I'm not sure. Please let me know what is out there. Links to demos would be great as well. Also, it would be very nice if you could see a preview of the image as you upload them, however I don't know if this is possible or whether it would work in all browsers... Please comment on that if you know the answer.
     
    forumposters, Feb 5, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    
    function add_upload_row()
    {
    	var table = document.getElementById('uploader');
    	var rows  = table.getElementsByTagName('td').length;
    	
    	if (rows >= 10)
    	{
    		return false;
    	}
    	
    	var input = document.createElement('input');
    
    	input.setAttribute('type', 'file');
    	input.setAttribute('name', 'file[]');
    	input.setAttribute('size', '20');
    	
    	table.insertRow(rows).insertCell(0).appendChild(input);
    	return false;
    }
    
    
    Code (javascript):
     
    nico_swd, Feb 5, 2007 IP