IE/FF XHR multi-file upload

P

pbd22

Hi.

I am trying to write a multifile upload script in javascript. So,
before the upload, my html looks like this:

<input type="file" id="file_0">
<input type="file" id="file_1">
<input type="file" id="file_2">
<input type="file" id="file_3">
<input type="file" id="file_4">
<input type="file" id="file_5">
<input type="file" id="file_6">
<input type="file" id="file_7">

I know, starting in FF 3.x, xhr binary methods are possible such as:

xhr.open("POST", "cgi-bin/posthandler.pl");
xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
xhr.sendAsBinary(file.getAsBinary());

But, how do I upload multiple files in "all versions" of Firefox and
"all versions" of IE? Is it possible? More detail needed.

Thank you.
 
B

Bart Van der Donck

pbd22 said:
I am trying to write a multifile upload script in javascript. So,
before the upload, my html looks like this:

<input type="file" id="file_0">
<input type="file" id="file_1">
<input type="file" id="file_2">
<input type="file" id="file_3">
<input type="file" id="file_4">
<input type="file" id="file_5">
<input type="file" id="file_6">
<input type="file" id="file_7">

I know, starting in FF 3.x, xhr binary methods are possible such as:

xhr.open("POST", "cgi-bin/posthandler.pl");
xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
xhr.sendAsBinary(file.getAsBinary());

But, how do I upload multiple files in "all versions" of Firefox and
"all versions" of IE? Is it possible? More detail needed.

I would advise an iframe in this case in stead of XHR. The same
functionality, look 'n feel, and way more compatible:

<form method="post" target="fr" action="cgi-bin/posthandler.pl"
enctype="multipart/form-data">
<input type="file" name="file1"><br>
<input type="file" name="file2"><br>
<input type="file" name="file3"><br>
<input type="submit">
</form>
<iframe name="fr" id="fr" style="visibility:hidden; display:none;">
</iframe>

'posthandler.pl' could then return some javascript code (e.g. an alert-
window) or send information to the parent page.

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top