Hey all
Can any one know how to make file upload control in javascript, for example using a texbox and a button :)
Thanks in advance
Kishh
Dupe of http://stackoverflow.com/questions/408735/javascript-file-uploads
Hey all
Can any one know how to make file upload control in javascript, for example using a texbox and a button :)
Thanks in advance
Kishh
Dupe of http://stackoverflow.com/questions/408735/javascript-file-uploads
Plain HTML:
<input type="file" />
To programmatically create one using javascript:
var el = document.createElement('input');
el.type = 'file';
document.body.appendChild(el);
If you need it to open a dialog (or if you need the ability to select multiple files) you need to use something like SWFUpload.
If my understanding is correct based on this and your previous topic, you're trying to upload a file PURELY in javascript. If this is the case, please note that this is not possible. You're going to need something on the server side to gain the request. Now, however, if you're looking for something that uploads in an "ajax" fashion, there are workarounds to do this by sending the request through a hidden iframe. I know JQuery has this capability built in.
It is impossible to complete your task using pure javascript and using no fileinput html tags, as it is the only thing that allows you to select/upload files. You can only style it.
The other way, as suggested by soprano, is to use some Flash/Java based uploader.
Although the author of the question asked about form file input styling, I want to let you know that pure JavaScript, AJAX-style uploads are possible with FireFox 3 and greater.
I wrote an exhaustive tutorial about this new feature on my blog.