> I've never seen javascript that could do this

Now, I'm not a javascript code, and barely know how
to use jQuery, the most user-friendly js system I've seen.
However, after a little searching, I ran across this
script, which the author says will automatically generate
the needed number of filefields, then, using an iframe,
create multiple forms and use them to submit the filefields 
one after another, thus uploading multiple
filefields with one pass.  (If I understand it all with only
a cursory review.)

It looks fairly simple.  Maybe I'll give that a try.

But here's the author's explanation:

The trick of my method is using multiple forms,
and using a hidden frame as the target of the form post.
I am creating multiple forms using a javascript loop,
just to make the total number of file upload fields variable
(defined by TotalFileFields variable). Each form contains
<input type="file"> element. When upload button is called,
each form is posted one-by-one, and thus dividing the
process into multiple relayed requests.

And here's his code from 
http://vinayakshrestha.wordpress.com/2007/03/20/javascript-multiple-files-upload-trick/


<html>
<head>
<script type="text/javascript">
TotalFileFields = 5;
StartUpload = false;
CurrentFormID = 1;
 
function FilesUpload() {
    while (1) {
        if (CurrentFormID > TotalFileFields) return true;
        if (eval('document.frm' + CurrentFormID + '.upFile.value') == ") {
            CurrentFormID++;
            continue;
        }
        break;
    }
    StartUpload = true;
    eval('document.frm' + CurrentFormID + '.submit()');
    return false;
}
 
function myIFrame_OnLoad() {
    if (!StartUpload) return;
    CurrentFormID++;
    if (FilesUpload()) {
        StartUpload = false;
        CurrentFormID = 1;
        alert('UPLOAD COMPLETE');
    }
}
 
function GenerateUploadForms() {
    for (i = 1; i <= TotalFileFields; i++) {
        document.write('<form name="frm' + i + '" method="post" 
action="http://localhost/";
target="myIFrame" enctype="multipart/form-data">');
        document.write('<input type="file" name="upFile"/></form>\n');
    }
}
</script>
</head>
<body>
<script type="text/javascript">GenerateUploadForms();</script>
<input type="button" value="UPLOAD" onclick="FilesUpload();"/>
<iframe id="myIFrame" name="myIFrame" onload="myIFrame_OnLoad();" 
style="display:none;"></iframe>




> -----Original Message-----
> From: Ian Skinner [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 28, 2008 2:06 PM
> To: CF-Talk
> Subject: Re: Pre-filling FileField Values
> 
> Rick Faircloth wrote:
> > I see your point.
> >
> > How do the multiple file uploaders in javascript or flash
> > get around this problem?
> 
> I've never seen javascript that could do this, once a bug in I.E. that
> allowed to was closed.
> 
> I did once read about an ActiveX that purported to allow this when used
> in I.E. but that was years ago.
> 
> Flash can do it since it is not a 'Browser' but rather a desktop
> application or something like it.  I've never played with this so I do
> not know the ins and outs, but that is my understanding.
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311740
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to