Kishh
Kishh

Reputation: 2055

File Upload in Javascript?

Does any one know how to make a file upload control in javascript. For example, one using a texbox and a button.


Dupe of Javascript file uploads

Upvotes: 1

Views: 4539

Answers (5)

Reputation:

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.

Upvotes: -1

bezmax
bezmax

Reputation: 26122

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.

Upvotes: 0

Evan Fosmark
Evan Fosmark

Reputation: 101651

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.

Upvotes: 1

Sophie Alpert
Sophie Alpert

Reputation: 143114

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.

Upvotes: 0

nickf
nickf

Reputation: 545985

Plain HTML:

<input type="file" />

To programmatically create one using javascript:

var el = document.createElement('input');
el.type = 'file';
document.body.appendChild(el);

Upvotes: 2

Related Questions