From: pbd22 on
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.


From: Bart Van der Donck on
pbd22 wrote:

> 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,

--
Bart