Multi-File Upload With Flex 2 and Coldfusion

Check out this example I have been tinkering on to demonstrate a flash interface with Flex 2 that will allow users to batch multiple files for upload. Note when trying the demo you can select mutiple files in the browse dialog box by control clicking or draging over your desired files.

The example uses a custom class file I created called MultiFileUpload. This class does all the work for you here is how to use it.

(this is an abreviated excerpt from the attached example source code)

<mx:Script>
<![CDATA[

import com.newmediateam.fileIO.MultiFileUpload;


multiFileUpload = new MultiFileUpload(
filesDG,
browseBTN,
clearButton,
delButton,
upload_btn,
progressbar,
"upload.cfm",
postVariables,
350000);
]]>
</mx:Script>

The MultiFileUpload class requires 9 parameters/data types; in the following order:

  1. DataGrid (this will the datagrid control that will show the file cue)
  2. Button (this will act as the browse for file button)
  3. Button (this will clear all files in the cue)
  4. Button (this will remove a single selected file from the cue)
  5. Button (this will initiate the upload of cued files)
  6. Progress Bar ( this will show upload progress)
  7. String (this string will be the destation of the server side upload script in the example the script is a coldfusion file
  8. URLVariables (this will be the object that includes any other variables or data you wish to send to the server with each file uploaded check the example's source code for how this works)
  9. Number (this number is the maximum file size a user can upload this number represents bytes, if a value of zero there will be no file size restrictions)

I'll be posting more on this demonstration as I work on it. In the mean time feel free to use it in your work (if you do send me a link), ask questions, request features or contribute to it.

- Ryan

Download Example

UPDATE September, 11 2006

Adobe has just published my new article about this demo to their developer center check it out.

Related Blog Entries

Comments
This is darn tootin nice. One suggestion - make a demo that isn't a full sized flex page. Wouldn't folks want to use this control inside another simple HTML form?
# Posted By Raymond Camden | 8/13/06 3:04 PM
I second that comment. Very cool implementation Ryan. I also wonder if there are businesss needs to enforce only compressed files are uploaded, or compress a file through flash and then send it in the stream.

On a side note. Can you do SwA (soap with attachments) with flex/flash?

Very cool example. Keep up the great work!
# Posted By Jonathan | 8/13/06 5:21 PM
Hi Ryan,
This is really cool, thanks`-`
I was not able to get it to work on my localhost:( I get:
[IO ErrorEvent type="io error" bubbles=false cancelable=false eventPhase=2 text="Error#2038"

I was able to compile the flex file, but then no luck uploading.
# Posted By John | 8/13/06 7:58 PM
yeah, fairly kewl. One thing I found when implimenting uploads in Flex, is that the mimetype is not passed in the header. FYI...

Just how does one get googed so fast? jeepers, I'm feel so left out of the goog boys club. :( boohoo

DK
# Posted By Douglas Knudsen | 8/13/06 11:32 PM
- Ray Thanks for the compliment, it wouldn't take much to implement the example into an html form or into another flex app. One could set the application size to dimensions that fit their needs and stip out everything but the panel and its contents. Next i'll be posting a simpler single file upload example in the next couple of days.
# Posted By Ryan Favro | 8/14/06 10:41 AM
- Jonathan if I understand you correctly you could upload and enforce only a zip file for example then and then unzip it on the server.

Modify this part of the MultiFileUpload class to enforce only zip files



//File Filter vars
private var _filefilter:Array;
private var imageTypes:FileFilter = new FileFilter("Images (*.jpg; *.jpeg; *.gif; *.png)" ,"*.jpg; *.jpeg; *.gif; *.png");
private var videoTypes:FileFilter = new FileFilter("Flash Video Files (*.flv)","*.flv");
private var documentTypes:FileFilter = new FileFilter("Documents (*.pdf)",("*.pdf"));
private var allTypes:Array = new Array(imageTypes,videoTypes,documentTypes);



And Make It Like this

<code>
//File Filter vars
private var _filefilter:Array;
private var compressedTypes:FileFilter = new FileFilter("Compressed Files(*.zip; *.rar; );

private var allTypes:Array = new Array(icompressedTypes);


</code>
# Posted By Ryan Favro | 8/14/06 10:46 AM
- John the IO error you have means there is problem with the server side script the possibilities are the path cffile path isn't correct if possible explain your set up a little bit more.
# Posted By Ryan Favro | 8/14/06 10:50 AM
- DK your correct flash player does not pass along the mimetype in the header instead it passed this "application/octet-stream" which is a binary file. The work around for this if your enforcing file types on the server is check the after the upload and if it dosn't meet the criteria then delete it.

For example:

<cfset fileType = #File.ServerFileExt#>
      
      
      
      <cfswitch expression="#fileType#">
      
         <cfcase value="jpg">
            <cfset filecheck = true>
         </cfcase>
         
         <cfcase value="jpeg">
            <cfset filecheck = true>
         </cfcase>

<cfdefaultcase>
            <cfset filecheck = false>
<cffile action="delete" file="#ExpandPath('\')#MultiFileUpload\images\#File.ServerFile#"/>
         </cfdefaultcase>
</cfswitch>
# Posted By Ryan Favro | 8/14/06 10:56 AM
I noticed that if the images directory does not exist that the PDF error file is created properly but the Flex app displayed that the file uploaded. Could the upload status msg be changed so that it goes off a returned value from CF.
# Posted By Aaron Rouse | 8/15/06 4:06 PM
Aaron you could modify the class funciton "httpStatusHandler" to throw the 500 error as string message to a label field.
# Posted By Ryan Favro | 8/15/06 4:12 PM
John, I got the same error message when I tried using it to uploaded files on a box that did not have CF 7.02 on it, perhaps it is a version issue for you?
# Posted By Aaron Rouse | 8/15/06 4:15 PM
Hi,
I was able to fix the issue that I was having. It seems that I needed to keep the files in the wwwroot of cf. I thought that when I changed the "\" to "/" that it would fix it, but it did not seem to matter.I had the files in a seperate folder, and when I just moved the files in the wwwroot, the problem was fixed`-` I would prefer to keep it in a seperate folder, but I am happy to have it working.

By the way I am using cfmx 7.02(on the mac), and now that I found this solution I am loving this app! Very cool stuff.
# Posted By John | 8/15/06 11:45 PM
I am unclear if the server changes the file name (since cffile is set to makeunique) you have no idea in your flex app that the file name changed. Can the .cfm file be changed to a .cfc and have it return an array of final filenames?
# Posted By Michael Ewles | 8/16/06 12:54 AM
Michael cffile is set to "makeunique" only if there is a file on the server that already has the same name. So for example if you had a file called "mycottage.jpg" and you uploaded a file also called "mycottage.jpg" cffile will append a "1" and not overwrite the other file so it would end up looking like "mycottage1.jpg" . Your second question is can the cfm file be changed to a cfc. The answer is yes but i wouldn't recomment it directly. Instead you can instanciate the cfc in the cfm file and return xml data as the page body after the upload occures. Also file upload does not work directly with Remote Procedures so you can use a cfc with Flash Remoting as directly as far as I am aware of.
# Posted By Ryan Favro | 8/16/06 10:26 AM
Ryan,

Do you plan to implement this component for IIS (ASP.net)? If not can you please give some suggestions/tips. I'm a newbie to flex/CF with very little programming skills.

Thanks
Venkat
# Posted By Venkat | 8/17/06 12:15 AM
Venkat,

At this point in time I have no plans to implement this into anything beyond FLEX and Coldfusion. However you can modify this example to work with ASP.NET, PHP, plain old ASP and just about any other scripting language out there that can handle "multipart/form-data" via http.

The two things you would need to change are as follows:

1. Replace the "upload.cfm" with an equivalant writtin in ASP.NET, PHP, JAVA etc...

2. Change the url value of the MultiFileUpload instance to match your new server side file

EXAMPLE:

multiFileUpload = new MultiFileUpload(
filesDG,
browseBTN,
clearButton,
delButton,
upload_btn,
progressbar,
"YOURNEWFILEHANDLER.ASPX",
postVariables,
350000);

I found a link for you to an asp.net example on how to handle file uploading.
http://www.codeproject.com/aspnet/fileupload.asp
# Posted By Ryan Favro | 8/17/06 12:19 PM
Very nice work!

A couple of questions though:

1. If using PHP instead of Coldfusion, will the progressbar work?

2. Does it use $_FILES()

Again, great work!

/Johan
# Posted By Johan André | 8/24/06 11:43 AM
Johan

To answer your question regarding if the progress bar will work under PHP, the answer is yes in fact the progress bar will work for what ever type of server side scripting language you choose to handle the file upload, and yes you can use $_FILES().

The is a php reference in the Flex 2 live docs with an example of this give it a try. http://livedocs.macromedia.com/flex/2/docs/wwhelp/... be patient with this link sometimes it slow to load.
# Posted By Ryan Favro | 8/24/06 3:01 PM
Cool!
Got it working now!

The progressbar is quite amazing actually, since all other uploadforms using PHP uses some other CGI-stuff to get it working... :)

Very clean and nice stuff!
/Johan
# Posted By Johan André | 8/24/06 5:57 PM
Johan

Glad to read you got it working. I am considering adding a property to the MultiFileUpload component to select whether or not the progress bar should show the aggregate status of the batch of files transfering instead of each file one at a time. Stay tuned and i'll post a refined version.
# Posted By Ryan Favro | 8/24/06 7:09 PM
Hello

Great work!!
But I want to know if there is a way to know if the upload is really complete because the COMPLETE event is dispatched even if the file is not on the server. I think flex doesn't wait for server reply to dispatch the event...
# Posted By Bryan | 8/25/06 3:34 AM
Bryan

I suspect your destination path in upload.cfm's cffile tag could be inccorect for your server configuration. The file upload.cfm uses cftry tags to capture any errors that may occur and thus the page will still return an http 200 code. This code is how flex knows the file upload is complete. Check your multifile upload directory for a pdf called 'errordebug.pdf' if this file is present it means you have a sever side error.
# Posted By Ryan Favro | 8/25/06 3:54 PM
Nice!

I'm going to use it for a cms i'm working on. (if it's ok with you ofcoz) :)
One cool feature would be to be able to give each file a name/tag (different from the filename) for easier finding and using of files later on.

Bye bye
Johan
# Posted By Johan André | 8/26/06 9:37 AM
Johan

Feel free to include this in your cms (send me a link once your done). Regarding. As far as renaming and taging the uploaded files it can be done. Flash Player its self cannot rename the file but the server side coldfusion component can. As for taging the files the example shows you can pass along additional data in the URLRequest from Flash Player to the server. Look at this excerpt from the example

FileUpload.mxml
----------------------------------------------------------------------------

var postVariables:URLVariables = new URLVariables;
postVariables.projectID = 55;
postVariables.test ="Hello World";

----------------------------------------------------------------------------

In the example this piece of code is non functional in that it does nothing once passed to the server side as I did program a listener for it. I placed it in the example to show that additional data can be passed with the uploaded files. On the serverside all you would need to caputure it would be #URL.project# and #URL.test# params if using coldfusion. So in the case of taging you could pass along the tags via this method. I hope this helps.
# Posted By Ryan Favro | 8/26/06 2:44 PM
Ahh.. I missed the postVariables stuff... :)

Got a working filemanager now...

I'll send a link when the cms is up and working...

Thanks for all your help!
Johan
# Posted By Johan André | 8/26/06 7:20 PM
Ryan,

First of all nice job on the uploader, its truely a time saver!

I was wondering if there was a way to pass in the postVariables a dynamic value that changes based on what the user has selected in another grid. I get this error " Only one file browsing session may be performed at a time"

any way to maybe reset or delete the fileMultiUpload instance before i create a new one.

Any help would be apreciated!

Thanks!
# Posted By Joseph Abenhaim | 9/10/06 12:14 PM
Joseph,

You could set the postVariables to be equal to another variable and set it to Bindable. In addition you can reset the instance of MultiFileUpload in the example by calling the init() function manually. As far as selecting another values from another grid is a little too vague for me. Send me a zip to ryanfavro at newmediateam dot com of what your trying to do so I can better comment on that.
# Posted By Ryan Favro | 9/10/06 8:57 PM
Hi Ryan,
First of all, thank you so much for posting this example. It's very nice of you.

I was wondering if you could help me how to use your component using Flash 8 and ColdFusion 7.1. ? I know I have to create a FLA file because you are using Flex, but I don't know how to call this component from a coldfusion page. I know nothing about xml or Flex. Please Please help! I really appricated.

Thank you for your time
# Posted By phuong | 9/11/06 7:39 AM
Phuong,

The MultiFileUpload class is written for ActionScript 3 and therefore requires Adobe Flash Player 9 to run (not to mention an ActionScript 3 compiler). You won't be able to directly use the class in a Flash 8 project as Flash 8 compiles ActionScript 2 for Flash Player 8. If you must use Flash 8 instead of migrating to Flex 2 there is still hope. Flash 8 introduced the flash.netFileReference and FileReferenceList classes that you can use to create similar functionality to my demo. Here is a url to the documentation on it http://livedocs.macromedia.com/flash/8/main/wwhelp... in addition try this example put up by Stephen Downs http://www.tink.ws/blog/filereference-example/ or this one by Oinam http://www.oinam.com/downloads/backups/fileuploadd...

Hope this helps.
# Posted By Ryan Favro | 9/11/06 9:52 AM
Thank you so much for your quick response. I didn't realize that I have to use actionscript 3 and Flash player 9 which I can not use in my application :(. I was temp to create a FLA in replace of your FLEX file to try to run the example. :)

Thanks a lot for clear me out,
Phuong.
# Posted By Phuong | 9/11/06 10:13 AM
This is a great tool for web programmers, so i just have a question about setting the postVariables after instacing the MultiFileUpload object. Is it possible??
# Posted By Anderson Maciel | 9/17/06 3:19 PM
Anderson,

I don't see why you cannot change the postVariables after the creation of the MultiFileUpload. Just make the postVariables variable bindable:

Example:

[Bindable]
var postVariables:URLVariables = new URLVariables;
postVariables.projectID = 55;
postVariables.test ="Hello World";

This sould allow you to alter the postVariable variable after its created.
# Posted By Ryan Favro | 9/17/06 4:14 PM
i keep on gettin a securityerrorevent 2049 when i try to upload a file. does anybody know why this problem occurs?
# Posted By virgil | 9/26/06 5:56 AM
Virgil,

There error you getting "2049   Security sandbox violation: _ cannot upload data to _." This is due to your path to the upload script being incorrect or the upload script is causing an error on your server. Confirm the upload script is working on your server first by building an html upload form. If that works then your path in the flex app is typo'd or incorrect. Check here for a list of runtime error codes should you get anymore http://livedocs.macromedia.com/labs/as3preview/lan...
# Posted By Ryan Favro | 9/26/06 12:36 PM
Hi Ryan,

First, congratz with this fabulous application. I love it and it works great with coldfusion. I'm now trying to write a php script for the flex front-end, but nothing happens when executed. Could you give a small example of a php-script that actually saves files on the server. I have already tried : http://livedocs.macromedia.com/flex/2/docs/wwhelp/... without result. I would really appreciate this, i'm really stuck.

Greetz,

Nesse
# Posted By Nesse | 10/10/06 10:21 AM
Nesse,

The reason nothing is happening for you when using your php script, is most likley due to the folder you are uploading your files too not have 'write' permissions set correctly. Below you you'll find a basic php snippet for uploading files via php. Just remeber to point your flex front end to it.

Snippet: upload.php
----------------------------------------------------------------------
<?php
$target_path = "images/";

$target_path = $target_path . basename( $_FILES['Filedata']['name']);

if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['Filedata']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>

----------------------------------------------------------------------
# Posted By Ryan Favro | 10/10/06 12:23 PM
Thanks Ryan,

You made my day. Keep up the good work. I'll spread the word.

Greetz,

Nesse
# Posted By Nesse | 10/10/06 1:29 PM
Ryan,

Thanks very much for the component. I was able to use it ASP.Net with few lines of code.

However, it seems like the component sends only one file at a time to through the service. Is there a way to send all the files in the datagrid at the same time?

ASP.net has a functionality to accept multiple file at the same time.
# Posted By Venkat Natarajan | 10/11/06 7:47 PM
Venkat , i'm thrilled to see you got the example working with ASP.NET. The really beautiful part of Flex is how agnostic it can be in regards to the wide variety ofserver side technology.

My initial gut reaction to transporting all the files in one call is it probably isn't yet possible. The package/class we use to move the file is called Flash.net.FileReference, FileRefernce has a method called 'upload()'. Now the upload method to work you need to feed it a URLRequest object. Below is the object from the fileIO class I created
------------------------------------------------------------------------------
_uploadURL = new URLRequest;
_uploadURL.url = _url;
_uploadURL.method = "GET";
_uploadURL.data = _variables;
_uploadURL.contentType = "multipart/form-data";
------------------------------------------------------------------------------

as you can see there isn't anywhere to put more images. With one exception you might possibly be able to pack them into a URLVariables object but i doubt it would fly. I hope this helps.
# Posted By Ryan Favro | 10/11/06 8:49 PM
Ryan,

Thanks for the response. Is it possible capture the count of the files in the DG and the index of the file being uploaded into the URLVariables?

Venkat
# Posted By Venkat Natarajan | 10/11/06 10:26 PM
How to run this upload app in TitleWindow?
# Posted By gorandri | 10/16/06 11:31 AM
Hi Ryan,

How can i prevent the following error:

Error: Error #2041: Only one file browsing session may be performed at a time.
   at flash.net::FileReferenceList/browse()
   at com.newmediateam.fileIO::MultiFileUpload/::browseFiles()

From a previous post --> "calling the init() function manually". I've tried this before but it doesn't work. I must be doing something wrong. Could u give me a bit more info on that matter?

Thx in advance Ryan.

Greetz,

Nesse
# Posted By Nesse | 10/18/06 3:50 PM
Nesse

Walk me through how you got this error to occur. Or send me your code if its easier.
# Posted By Ryan Favro | 10/18/06 4:17 PM
Ryan,

I'm gonna make a quick example in flex. can i mail it to you, or post it somewhere?

Thanks for your time.

Greetz,

Nesse
# Posted By Nesse | 10/20/06 4:15 AM
Neese

Drop into my email ryanfavro[at]newmediateam[dot]com .
# Posted By Ryan Favro | 10/20/06 4:28 AM
Hi Ryan,

Did you receive my mail with the example project? Otherwise i will drop it into your email ryanfavro[at]newmediateam[dot]com again.

Greetz,

Nesse
# Posted By Nesse | 10/24/06 5:43 AM
A few questions:

When I create a project called MultiFileUpload Flex automatically creates a MultiFileUpload.mxml as the default application. Is that supposed to happen? Should that be deleted and FlexFileUpload.mxml be made the default?

Your example app on your site calls FileUpload.html, I get FlexFileUpload.html. Should I be seeing the FileUpload.html?

The .cfm file refers to /uploadedfiles folder, should that be /uploadedFiles instead?

thanks
# Posted By tomas | 11/1/06 10:31 PM
Hi Tomas,

The view source on the example is actually not in sync with the download. When you are downloading the example it’s actually in reference to the article I wrote for Adobe's developer center back in September http://www.adobe.com/devnet/coldfusion/articles/mu...
I haven’t had the chance to modify the example that is posted to here to fully match my Adobe article's version. Use the Adobe version as your reference. Also the .cfm file is not case sensitive so either is fine.
# Posted By Ryan Favro | 11/1/06 10:52 PM
I'm a CF newbie but I've managed to get the cfm file to write to a database with this after the cffile tag:

------------------
<cfquery name="test2" datasource="rconsole">
INSERT INTO PHOTOS(IDUSER,TAG, PHOTONAME)
VALUES('#URL.user#','#URL.tag#' , '#File.ServerFile#')
</cfquery>
------------------
My only problem is setting the tag in postVariables. I can only figure out how to set this on the init call. How can I set this after the tags are typed in?

Very cool script Ryan, thanks a lot.
# Posted By Rodney G. | 11/2/06 2:26 PM
Ryan, simply amazing. I love it! Seirously good work.

I know this sounds like a stupid quesion. Have you run into any issues with the FileIO on Mac and or Firefox? Seems to cue correctly and the progress bar moves, but no files upload.
# Posted By Tim Mushen | 11/8/06 8:15 PM
I'm getting an error, this is from the pdf file <br>CFFILE action="upload" requires forms to use enctype="multipart/form-data".

any ideas?
# Posted By Steve | 11/12/06 12:29 AM
Rodney, i'll be posting a new example within the week on how you can bind to the postVariables so please stay tuned.

Tim, As far as I know the fileIO on Mac and Firefox should work the same across all browsers. Did you check the server side to see if an error pdf was generated?

Steve, the error you are getting means that the request being made from the file uploader isn't being encoded as multipart/form-data. Make sure in the MultiFileUpload.as class you have the following code present:
------------------------------------------------------------------------------
// Set Up URLRequest
    _uploadURL = new URLRequest;
    _uploadURL.url = _url;
    _uploadURL.method = "GET"; // this can also be set to "POST" depending on your needs
   
    _uploadURL.data = _variables;
    _uploadURL.contentType = "multipart/form-data";
------------------------------------------------------------------------------

The last line here is where you set the contentType of the URLRequest object that gets sent to the server. The URLRequest object works like how an HTML form request would work. You need to set its method, contentType and variables to be sent to the server. Hope that helps.
# Posted By Ryan Favro | 11/12/06 4:53 AM
The multiFileUpload.as has that code in it. I also tried changing from GET to POST with no luck. the pdf file is here www.farwelldesign.com/flex/MultifileUpload/errordebug.pdf
# Posted By Steve | 11/12/06 3:12 PM
Ryan, thanks a ton. We're using this our backend crm system. I was able to add some additional args, as well as dumb down for just a single upload. I will be repurposing!

On a side note, check your .zip as a whole. You may have updated since I last grabbed, but there was an extra main app file in there that was blank and messed me up for a bit. FB grabbed the blank one by default and caused me a little chaos.. and your doc didn't reflect the name of the new one..

But got it up and running THX A TON!
# Posted By Steve | 11/14/06 2:11 PM
Thanks for the tutorial and code Ryan. I am busy implementing the code with PHP with great success. I was wondering about two things: 1) How would resuming a broken upload be implemented and 2) What will it take to add download functionality to the code? Any thoughts appreciated.
# Posted By Dearheart | 11/15/06 5:19 AM
Dearheat

In theory if the file upload dosn't complete the server will throw some sort of http error like a 500 error if the serverside fails. You could write a multiple attempt script with a timeout and some sort of re-attempt logic.

Adding download functionality is very simple. There is a method in the flash.net.FileReference class called appropriatley called download. There is a Adobe livedocs on this here http://livedocs.macromedia.com/flex/2/docs/wwhelp/... You'll have to scroll to the bottom third of the page to see the example. I hope that sets you on the correct course.
# Posted By Ryan Favro | 11/15/06 10:40 AM
I was able to use this with Websphere instead of coldfusion where a servlet is accepting the upload files. It works fine when the web server(IIS) is accepting anonymous authentication. However, when the IIS web server is changed to accept only the Integrated Windows authentication, it would display the prompt for login id and password. It should not have because I'm logging into the network with the proper permission. It still would not upload the file after providing the id and password. Any idea?
# Posted By Van | 11/15/06 11:15 AM
Hey there. Great work on this class. A real help to all of us.

Quick question: If I plan on using a CFC to process my uploads, then what variables should I be sending to it? i.e. If I send the _file variable I get back the message that cffile="upload" requires multipart/form-data anod not the amf I am sending.

Any ideas on that?

Thanks!
# Posted By Kenny Silanskas | 11/18/06 2:11 PM
Hi Van,

I have not encounted your situation yet, so i'm not exactly sure why are you getting the error. My gut reaction is that because Flash Player is stateless it is not respecting the handshake that is made when you authenticate to IIS. Drop me an email with a link and we'll try to solve this one.
# Posted By Ryan Favro | 11/19/06 1:38 AM
Kenny,

Think of the way flash player uploads data as an imitation of the way a standard html form works. If you want to use a CFC to handle the upload my advice is to call it from within a regular CFM template.
# Posted By Ryan Favro | 11/19/06 1:42 AM
Here is a quick and dirty example of to create a file downloader in Flex 2 http://ryanfavro.newmediateam.com/blog/index.cfm/2...
# Posted By Ryan Favro | 11/23/06 2:01 PM
Can omeone please help troubleshoot this error? It occurs after the file has uploaded to the server and then crashes the browser. I do not get this if I use Apache/ColdFusion on a local machine. But if I try this on a remote machine in my domain it fails. Here is the errors from Flash:

RangeError: Index '0' specified is out of bounds.
   at mx.collections::ListCollectionView/removeItemAt()
   at edu.edadmin.helpers.fileIO::MultiFileUpload/::completeHandler()
   at flash.media::Sound/play()
   at edadmin/uploadsfinished()
   at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at edu.edadmin.helpers.fileIO::MultiFileUpload/dispatchEvent()
   at edu.edadmin.helpers.fileIO::MultiFileUpload/::completeHandler()
# Posted By Richard | 1/11/07 4:37 PM
Excellent application... i have got it working using Asp.Net..

I have found a problem though... in action script we are giving the server path to upload.. if we give it as http://www.digitalmesh.com/upload/uploader.aspx, it wont work for urls without www. it will throw a security exception.. Vice versa is also a problem..

To see the bug please try http://www.digitalmesh.com/anztest/upload/fileuplo...
and
http://digitalmesh.com/anztest/upload/fileupload.h...

Regards
Anz
# Posted By Anz | 1/18/07 2:31 AM
Hey Ryan, I am new to this software and flash has a whole so this may be easy one to answer for you. I am wondering how i could pass to the swf an id from the database. I see that you have the var postVariables:URLVariables = new URLVariables;

and this works if i put the number in manualy to 25018 insted of hello world i can easily get it on the upload page. but how do you pass to the swf that id that i need to pass to it, this is little piece of my code
var postVariables:URLVariables = new URLVariables;
postVariables.slideid = slideid;

but that slideid, i am not sure how to make it so that the i can pass it this id. not sure if this is clear but please let me know when you get this thanks.
# Posted By Jean-Luc | 1/22/07 10:01 AM
Richard,

I've never seen that error before, contact me at ryanfavro[at]hotmail.com and we'll sort it out and post our findings.


Anz

I tried your link and it seemed to work fine. Just a little hint, when you define the URL to your upload script you don't have use a fully qualified domain name, instead you can use a relative path to your flex swf if the swf and the upload script are on the same site.

Jean-Luc

If you are defining the variables on a page load, you can use FlashVars to do this. I'm a bit strapped for time at the moment to post a demo, but if you look up FlashVars in your Flex/Flash documentation that should lead you in the correct direction.
# Posted By Ryan Favro | 1/23/07 12:27 AM
Hi,

I'm getting a security error in safari 1.3.2 any ideas?

[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2049"]
# Posted By brett | 1/30/07 6:54 PM
Ryan,

Very well written AS class. Hat's off to you!

I am experiencing a problem and I'm certain it's with in flash it self and not part of you code. It seems that any file over 400K or so stops during the upload.

FYI:
I did change your _maxFileSize to 0.
I have tried it using asp and php.
I have tried it on multiple servers.

Which from my perspective leaving it as a limitation or bug in Flash.

Any advice?

Thanks...
# Posted By Jeff | 2/25/07 5:48 PM
Any chance you could add a feature that would show a thumbnail of the images after they are uploaded and allow for a caption / description to be entered for each one?
# Posted By Nate | 2/28/07 12:01 PM
For those getting the SecurityErrorEvent 2049 error:

Assuming that your upload script works and that you have the correct URL to it in the FlexFileUpload_cb.as file, you may want to try accessing the HTML file through the URL for it instead of through the file for it.

In other words, if I had this in my URL, I would get the error:

file:///C:/Inetpub/wwwroot/MultiFileUpload/FlexFileUpload.html

If I had this instead, it worked perfectly:

http://127.0.0.1/MultiFileUpload/FlexFileUpload.ht...

Same file.
# Posted By Gabriel | 3/2/07 11:09 AM
I have this working with a RubyOnRails backend. However, it doesn't seem to work with anything but Windows IE.
Firefox on Windows or Linux acts as if it is working, but the file never arrives.
Running the swf on a Mac (Safari, Camino, Firefox) produces :
[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text+"error #2038: File I/O Error. URL: http:x.x.x.:3003/client/fileUpload?"]

Any idea what would cause the problem? Is it a problem with the Rails backend?
# Posted By Bruce | 3/7/07 11:03 AM
Hi Bruce

Error 2038 is a File I/O Error and that comes from the server side not being able to process the file for one reason or another. I'm don't use ROR so thats about as far as i can help you with.
# Posted By Ryan Favro | 3/7/07 12:06 PM
I have an interesting effect, which from my point of view seems to be more a bug in the Flex compiler than in your class: I have simply tried to put another datagrid besides yours to add a view to the already uploaded files. I put both in a divided box:

   <mx:Array id="provider"/>


      <mx:HDividedBox>
<mx:DataGrid id="filesDG" left="0" right="0" bottom="30" top="5"/>
<mx:DataGrid id="filesUploaded" dataProvider="{provider}" left="0" right="0" bottom="30" top="5">
       <mx:DataGridColumn dataField="name" headerText="File"/>
</mx:DataGrid>
      </mx:HDividedBox>

Here is the strange thing: It wont compile, and this is the error:

Multiple initializers for property 'dataProvider'. (note: 'dataProvider' is the default property of 'mx.controls.DataGrid').   

If I remove the dataProvider attribute, strange datagrid columns become visible instead...

I found out that you get this behavior for every DataGrid below the "manipulated" one in the mxml file...

Can you reproduce this? Any ideas how to fix this?

Thanks, Kolja
# Posted By Kolja | 3/15/07 6:00 AM
Hi Ryan,

Thanks for nice upload component.

I am trying to implement it with PHP as a backend. The problem I'm having has already been discussed before - how to propagate user session to pages that you access with Flash network request.

Here are two links on the topic:

http://www.mail-archive.com/flexcoders@yahoogroups...
http://www.rooftopsolutions.nl/article/117

Have you been able to figure out the best way of doing it?

Here's the scenario in details:

1. Upload page containing SWF uploader is accessible to authorised users
2. A user logs in on HTML page (plain old <Form/>) and gains access to HTML page containing SWF uploader.
3. Files are posted to "upload.php" on the server.
4. upload.php should already be aware of the existing user session to place uploaded files into user's home folder and to create correct database records.

So the problem is with item #4. A new session is created by upload.php, thus losing authentication info.

Any ideas on how to solve it?

By the way, I experience this problem only with Firefox. Oddly enough, in IE "upload.php" does remebers the session!

Thanks,
Temuri
# Posted By temuri | 3/24/07 8:56 PM
I am almost ashamed to ask this...okay, I am TOTALLY ashamed to ask this question:

Where do I see the files I've uploaded on my localhost?

I compiled everything and placed in my wwwroot in cf and everything works. I get the 'ding' after I upload a .jpg, but I don't see anything in the folder after it completes.

Sorry for being so noob.
# Posted By marty | 3/25/07 1:55 AM
Nevermind :)

I saw that coldfusion generated a nice error file for me that told me to create a MultiFileUpload/images folder and it worked.

I still feel stupid, if it's any consolation :)

This is really is a great application. *Thanks* for making the code public, so others can benefit from your expertise.

Best,
Marty.
# Posted By marty | 3/25/07 2:01 AM
This is an excellent component, very simple to implement. Thanks very much for this..

Chris
# Posted By Chris Boyce | 4/5/07 2:54 PM
I've got this working on my site. It works for around 50 or less files but more than that it starts to throw 2038 error. Is this an issue with the ActionScript vm not being able to handle the size? I'm at a loss and would be interested in your thoughts.
# Posted By Ryan | 4/26/07 6:26 PM
Hiya Ryan, fantastic stuff this article. readable and well documented code that really helped get me into doing something a bit similar in flex.

A few wise-ass remarks though ;)

i think you mean queue(as the one you stand in line in), not cue (the one yo ushoot pool with)

kb should be kB (not that anyone who knows the difference will believe it's bits anyhow)
# Posted By yab - yet another blogreader | 6/10/07 1:51 PM
Yab,

I'm happy you enjoyed the article, I do try my best you know.

Regarding my use of the word cue (versus queue) the words are synonyms. Perhaps this is the more Canadian way to spell it( btw I'm Canadian).

http://www.answers.com/topic/cue

You are also semi right about the kb. It should be KB rather then the kB you suggest. As kB contextually refers to 1000 bytes. KB generally means 1024 bytes and the example divided its byte count by 1024 to determine how man KB the files are. But it in the end whats important is the readers take away some valuable Flex knowledge.
# Posted By Ryan Favro | 6/10/07 9:46 PM
I want to add the functionality of that when you upload files to the server it will also upload the names of the file to the database. I tired to do this inside upload.cfm but seems to break the upload. Ideas???
# Posted By Justin | 6/12/07 6:07 PM
Hi Ryan - very nice component that i have customized for my needs (added a page count on documents uploaded).

Now a question : i tried to convert it to an AIR (ex-Apollo) app, but i'm facing a problem. It seems that the filedata field sent to the page upload.cfm is empty (it's what the dump says). Do you have any idea of what could be wrong ? A security problem (cross-domain or http get ?) ? I'm just starting to play with AIR, so i'm a bit confused :-)

You can contact me directly by email when you'll have some time...

Thanks in advance,
Cyril
# Posted By Cyril | 6/14/07 6:09 AM
Hi,

If anyone got it working in asp.net, can you post the asp.net source. I'm stuck.

Thanks,
Ash
# Posted By ash | 6/27/07 5:51 PM
This is an awesome piece of code. I just showed my coworkers and they said that this was something they've wanted for years.

Just one problem. It only works in IE. I get the 2038 error when I run the application in firefox or safari.
# Posted By Andrew | 6/27/07 9:32 PM
Andrew,

The example runs under all browsers with flash player 9 on windows and mac, at least according to my tests. Do you get the error in my hosted example or only when you implement the code?
# Posted By Ryan Favro | 6/27/07 10:41 PM
Ryan,

I've implemented the code in my own application. This application is a portal that uses modules to load various functions. I'm able to upload files running the application in IE, but it fails in other browsers with the 2038 error.

Maybe its a difference in ActiveX flash vs component versions, I'm thinking IE does things a little differently.

One other thing, I am using https connections, but that shouldn't be an issue. It's not the 2049 error I'm seeing.
# Posted By Andrew | 6/28/07 12:55 PM
Ryan,

I just tested your application as written on my servers using HTTPS connections. The application fails with 2038 errors if not run in IE.

Cheers,

Andrew
# Posted By Andrew | 6/28/07 1:16 PM
Andrew email a link to your version with https. I have a hunch that the https might be the culprit. What I want to do is run the application under safari with it's activity window open to see if shows anything odd.

my email is ryanfavro [at] hotmail [dot] com
# Posted By Ryan Favro | 6/28/07 1:30 PM
Andrew,

did you try to change the method from GET to POST ? I had the same issue when trying to make it run under Apollo, changing the method solved my problem.
# Posted By Cyril | 6/29/07 10:53 AM
Cyril,

I've not tried the post / get change. I've just changed the upload program to run in http mode rather than secure.

The files being uploaded are mostly made available for web galleries and so don't need to be secure.
# Posted By Andrew | 7/3/07 6:05 PM
Hi, I have similar problem with FLEX an PHP upload handler. Everything works perfectly on localhost Apache server, but as soon as I deploy the application to my ISS webserver (Aruba.it) I had the IOError #2038 Flex error at the end of files upload (doing some HTTP loggin I discovere it's an HTTP 403 error). The problem is that Flex has a small bug in transfering files (you can find it in Adobe docs), because it tranfers with "final boundary missing" in MIME request. So if you have an ISS with Linux Server you should set .htaccess file adding this 2 lines:
SecFilterEngine Off
SecFilterScanPOST Off
Then if you have an ISS with strong security policies (for example you cannot put this lines into the .htaccess file) you can't run properly your application... I'm still trying to find out a new solution, but I think I should unfortunately choose another technology...

You can find my application here:
http://www.discofonz.it/utils/FileUpload/bin/FileU...
# Posted By NightFox | 7/4/07 4:40 AM
Hi Ryan,
AWESOME Component!!!

I have a few feature requests, or maybe you could point me in the right direction and i can just do it myself :)

i have your example working brilliantly. I have added a few features.
on the cf side, i make the output silent, and keep track of a status code and message, if all is good, i send nothing back otherwise i send the code and message back,
<code>
upload.cfm .....
bottom of the file....
</cfsilent>
<cfsavecontent variable="x">Data=<cfoutput>#status#</cfoutput></cfsavecontent>
<cfif code GT 202><cfoutput>#TRIM(x)#</cfoutput></cfif>
</cfprocessingdirective>

</code>


the file upload tool will pick that up and alert the message to the user. (EG File to big, bad file, ect..)
<code>
... multiFileUpload.as ....
private function httpStatusHandler(event:HTTPStatusEvent):void {
// trace("httpStatusHandler: " + event);
if (event.status != 200){
mx.controls.Alert.show(String(event),"Error",0);
}
}

</code>


What i would like to do now is skin the grid and slick it up.
i want to add a progress bar for each file to upload.

Can you give me some suggestions on updating each progress bar inside a datagrid?

Again thank you so much for your contribution!

Regards,
Tim
# Posted By Tim G | 7/5/07 6:28 PM
Thanks Ryan for this excellent upload tool. However, I'm trying to add a combo box (select box) to select a particular directory to upload the files to. I know that the postVariables would do the job, but I'm new to Flex. So, how do you post the directoryID dynamically to this postVariables so I can use coldfusion to manipulate this value??? Any help will be greatly appreciated.
# Posted By Vincent | 7/9/07 2:57 PM
to NightFox:
Thanks a lot dude, your method works.
# Posted By Ivaylo Alexandrov | 7/11/07 4:13 AM
Hi all,

I'm facing the same problem than Andrew.

With http, everything's ok. With https, error 2038 at upload start.

I've tried Cyril tip by changing method from POST to GET but it doesn't change.

Does Ryan or anybody have succeeded in working with secure upload ???

Thanks all
# Posted By Gromit | 7/16/07 2:26 PM
I am having the same HTTPS issue with error 2038. This is very annoying I can get it to work without HTTPS but that solution is not acceptable for production as it requires SSL... Anyone get anywhere with this?

Matt
# Posted By Matt | 7/23/07 7:27 PM
This MultiUpload is good if you want to use the default interface, but once you want to create your own interface to the multiupload class you made then it cannot be used.
# Posted By Jamal Soueidan | 7/27/07 3:15 AM
I don't understand why Jamal ? I created an extended version of the component by adding other functions needed in my application (page count for word documents) and even created an AIR version (well, it's easy i know). And for the interface itself, you just have to enter into the code and change it so that it suits your needs.
# Posted By Cyril | 7/27/07 3:36 AM
Well, you shouldn't edit the original class, you should extend the class and create your own functions.

I'm developing new multi upload class that fits people to extend it and doing their own UI interface etc.
# Posted By Jamal Soueidan | 7/27/07 4:08 AM
Thanks for making this app. Its awesome!

I'm trying to pass in the value for uploadDestination, so it is not hard coded, and since I'm a newbie, I'm having difficulty with it. Could you help?

I changed the following line in FlexFileUpload_cb.as from

public var uploadDestination:String = http://www.xyz.com/Upload.cfm";

to:

public var uploadDestination:String = Application.application.parameters.uploadUrl;

Then, in the index.cfm file that I have the flash file on, my flashvars code is as follows:

"flashvars",'uploadUrl=<cfoutput>#urlEncodedFormat(uploadActionString)#</cfoutput>&historyUrl=history.htm%3F&lconid=' + lc_id + '',


I can build the file fine, but when I go to run it, I get the following error and the flash movie does not show:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlexFileUpload$iinit()
at _FlexFileUpload_mx_managers_SystemManager/create()
at mx.managers::SystemManager/::initializeTopLevelWindow()
at mx.managers::SystemManager/::docFrameHandler()


Once again, thank you. If you can help me, I'd greatly appreciate it. Thanks.
# Posted By David G | 8/1/07 12:04 PM
Thats because String is null and you are trying to access it.

this leads to Application.application.parameters.uploadUrl which is null!
# Posted By Jamal Soueidan | 8/12/07 4:02 AM
Is there a solution for the non-IE upload issue?
# Posted By Russ | 9/4/07 10:48 AM
Hi Ryan:
Thanks for sharing this. It's great.

A question:
I have created a hyperlink on a CF page that launches the Multi File Upload and passes several variables in the URL:
<a href="\MultiFileUpload\FlexFileUpload.html?Destination=#fldType#\#fldShortName#\Exhibits">Upload Exhibits</a>

How would I get my "Destination" info to the "Destination" path in the <CFFILE> on Upload.cfm?

Sorry, I have basic CF skills but am newer to OOP.
# Posted By Andy | 9/4/07 12:51 PM
Hi Ryan, thanks for sharing this, its great.
I have tried it using ASP & it works, I tried to customize the same by adding one more column to the datagrid - Image Preview(thumbnail).
I am unable to display the image in the new column.

Could you suggest something ????
# Posted By Raju | 9/7/07 3:22 AM
have u used the proper itemrenderer to show the thumbnail image?!?
# Posted By Hazem Adawie | 9/20/07 5:22 PM
Itemrenderers will not work as the FileReference class does not allow developers to read files from a user's machine directly. Meaning it does not return a path to the file, only a file name reference.
# Posted By Ryan Favro | 9/21/07 1:16 AM
Hey Ryan,
Incredible app. Thanks. I sucessfully "imported" the value of a querystring from the flash file (the path where My upload needs to go) each path is dynamic and different for every client, how can I now pass this value along in the URL variables to the upload page so the files go into the appropiate folder path?

Right now I am using the following to get the query string value of foldername:
Application.application.parameters.foldername

Kindly help!

--
Thank You,
Frank
# Posted By Frank | 9/26/07 8:43 PM
Anybody with I/O issues try turning off Service Capture if you are using it. It causes me all sorts of problems with uploads.
# Posted By Josh | 10/22/07 9:57 AM
Hi,

Thanks for sharing this Ryan.

Has anyone had any luck getting the upload to work over HTTPS using Firefox?

Thanks, Gerry
# Posted By Gerry McLarnon | 10/24/07 4:58 AM
FYI for those who have installed OS X Leopard be aware that there is currently an issue with Flash Player's FileReference Class. Until there is a patch or update this application does not work on OS X Leopard regardless of the browser.
# Posted By Ryan Favro | 10/29/07 10:45 AM
Is there any way to show a defined image size after uploading the file?
# Posted By Guillermo Villa | 10/30/07 4:51 PM
Hi Gerry,

Talking about the https problem, I contacted Adobe support team so that could fix the bug.

Whereas thousands of people on the internet as succeeded in reproducing the problem, the flex team did not. After tons of emails and explanations, I stopped contacting them and they closed the bg request.

If you have enough time, patience and courage, you can try on your own and I will be glad to hear a solution.

Thank you
Bye

Gromit
# Posted By Gromit | 10/30/07 7:14 PM
Ryan, this is really cool. I had a few errors but after running thru comments on blog I figured it out but still have 1 problem. You mentioned passing paramaters using coldfusion, I want to be able to pass the file name and location of file to a SQL insert statment so that I can show documents that were uploaded for a project. Would I just do a reference to the datagrid that had information?

Any help would be greatly appreciated.
# Posted By Alfio Raymond | 11/9/07 4:25 PM
Thanks Ryan for the great work and appreciate sharing it.

However, when trying to upload a 30MB file with a low bandwidth (internet connection using a modem), I get the
[IO ErrorEvent type="io error" bubbles=false cancelable=false eventPhase=2 text="Error#2038"] error.

Is this a known issue? If so, any solution? If not, any suggestions?
What about this .htaccess file? Where to copy this file if I am running IIS on a Windows 2003 Server? Also, any security concerns using this .htaccess file?

Thanks in advance.
-WC
# Posted By WC | 11/10/07 1:07 AM
What do you know about creating a folder for the files to be uploaded to. Have you seen the ASFUSION file explorer. I am using a modified version but it has issues that are still bugs errors or whatevers. I want to make the same app in flex 2. What are your thoughts about the file creation? I want to use upload file/folder including DB to reproduce a tree for browsing the downloadable files. I think that does not make scence but im trying....

any thoughts?
George
# Posted By George Smith | 11/13/07 11:40 PM
I know this project is over a year old but I wanted to ask you something.

Have you tested this on Firefox and Safari? for some reason it will only work on IE for me, I though Flash didn't have cross browser issues. Or maybe its something on my server but on IE works fine, FF or Safari wont :S
# Posted By Raul Riera | 11/15/07 10:13 AM
thanks Ryan Favro
# Posted By aziz | 11/26/07 9:55 AM
Thanks for sharing for this important things..
thanks
# Posted By Posin | 11/29/07 5:31 AM
If anybody is having problems uploading larger files, there are 2 things you need to do:

First, you need to go into IIS (on windows) right click on the website you are using, and choose properties. Then set the connection timeout to something larger than the default of 120 seconds (2 minutes). If an upload is taking more than that it will just stop the upload.

Second, If you are using ColdFusion, set the Maximum size of post data (MB) to the max size you want to allow to be uploaded. For instance, Flex will allow you to upload the large file, but if it is larger than what is set above, ColdFusion will not save it and throw an error.

I hope this helps people trying to upload larger files. This has frustrated me to no end and I finally figured it out.

--
Frank
# Posted By Frank D'Elia | 11/29/07 8:10 AM
Hi Rayan,

Thanks for your file upload concept. It is very much useful for me.

Regards,
Sasi
# Posted By Sasikumar | 11/30/07 12:32 AM
Hi,
I am new to flex. When i use this code, the error is shown in the mxml editor itself. There are two errors:
1) Compile time constant error
2) Undefined method MultiFileUpload

I dont know how to come through this problem. Can any one help me out for this?


Thanks,
Saravana :-(
# Posted By saravana | 12/5/07 2:07 AM
I downloaded the source and compiled it with the flex compiler. It seems to work ok, except that i cant see the progress bar.

Any clues?
# Posted By Adil | 12/6/07 7:25 AM
I have setup the application in more or less its native form. However I get this error when uploading large files even though though the variable is set to 0. The Flex app never talks to the CF it errors out before the upload is even finished. I have also been testing for server time out but the error seems to happen randomly during upload.

Any help would be greatly appreciated.

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2038"]
# Posted By matt | 12/6/07 10:42 AM
I saw that some people had success in getting this to work with ASP.NET. Any pointers you can give me?

Thanks.
# Posted By James W | 12/13/07 9:08 AM
Ryan, awesome tool by the way. I found it on Adobe's developer site first and I eventually found this site. Great stuff. Thanks.
# Posted By James W | 12/13/07 9:10 AM
Hello Ryan,

I am currently working on a similar application. In this i trying to upload a file and then insert data from it. I am trying to make flex talk to my servlet in web-sphere. so the URL in the action script is refering to the servelet mapping in my web.xml.
Now when i try to upoad, it promts with IOError.
The application is security enebled, and when i try to hit the same URL in the Browser it askes me for authentication which i think is the problem.
Can you kindly suggest me how should i go about this.
# Posted By Girish Mallampalli | 12/19/07 5:53 PM
good god man. Your are just the damn coolest. I set this up on PHP exactly as you suggested and it worked. It worked the FIRST time I tried it. No modifications, no panics, no groaning, no sifting through the code... it just WORKED.

You deserve a friggin medal. Thank you for saving me hours of headaches. You have made my night. Kudos and good fortune to YOU.
# Posted By Angel | 1/9/08 12:47 AM
Tyvm!! you are awsome!!.. all others blog didnt work.. now i wanna help you with something..
# Posted By Rsam | 1/11/08 5:42 PM
1st, sorry for the dumb ?'s i know you dont want to answer them..

Im curious if this works with flex beta 3 (milestone4) because im trying to get my feet wet in flex and have a few ?'s.
#1 why name the project MultiFileUpload if your mxml is named something different? i tried to name it MultiFileUpload and unzipped the files and i have a blank flex project, which makes sense.. now if i copy the code from your mxml and paste it in mine i have to add a ../ to the .as and .ccs imports to make them link right then i have 2 errors when i run the app.

"1046: Type was not found or was not a compile-time constant: MultiFileUpload.   MultiFileUpload/src   FlexFileUpload_cb.as   line 12   1201467131325   84"

and


"1137: Incorrect number of arguments. Expected no more than 0.   MultiFileUpload/src   FlexFileUpload_cb.as   line 46   1201467131367   86"

and it loads the stuff in flex but it says "loading 0%" in the bar and the browse button doesnt do anything
# Posted By Aaron Alexander | 1/27/08 3:55 PM
Hi, i am trying to get this to work with Air / Flex B3
i can run this code fine as a Flex app but when i switch it to a AIR ap i get the horrible [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2038: File I/O Error. URL: http://myURL/multifileupload/upload.cfm?projectID=... errorID=2038]
Error

The exact same code runs in a mx:Application but not in a mx:WindowedApplication


Thanks
Nick
# Posted By nickuk | 1/30/08 9:49 AM
I seem to figured out the problem with this component and Safari and Firefox, the problem is explain in this little scenario I ended up in.

I have a custom CMS that restricts access to the folder "admin" (where everything is located) and using CFLOGIN but I also have a Flex MultiFile upload in there that points to an "upload.cfm" inside that same admin folder. For some reason this work perfectly on IE, but on Safari or FireFox (both Mac or Win) the session gets lost when Flex makes that call to the upload.cfm inside the restricted folder (it shouldnt because if you are already there it means you are logged)

I solved this by adding an IF to my Application.cfc to not to check for logged users to use the upload.cfm (which is bad, but its a solution whatsoever) Seems to me like a major issue with FireFox and Safari. Any ideas on how to solve this, or if they are aware of this bug?
# Posted By Raul Riera | 2/5/08 2:33 AM
Thanks Ryan - that worked a treat with a asp.net backend.

File you post to as e.g.
public var uploadDestination:String = "http://your_domain.com/receive.aspx";

receive.aspx:

<%@ Import Namespace="System.IO" %>

<script language="vbscript" runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim hfc As HttpFileCollection = Request.Files
For i As Integer = 0 To hfc.Count - 1
Dim hpf As HttpPostedFile = hfc(i)
If hpf.ContentLength > 0 Then
'Save the file to some mapped location i.e. "MyFiles"
hpf.SaveAs(Server.MapPath("MyFiles") & "\" & Path.GetFileName(hpf.FileName))
End If
Next i

Catch ex As Exception
'some backend error handle
End Try
End Sub
</script>
# Posted By Jon Wortley | 2/18/08 4:22 PM
first let me say there is a lot of crap posted as code on the web for Flex but after copying your code and setting it up in 30 minutes it worked!! truly amazing. you've restored my confidence that people like you exist and make other developers life easy!! super job!!!
# Posted By LeeH | 3/2/08 4:02 PM
i've got this working standalone but now i want to move this to an existing flex app. the existing app has a tabnavigator. i guess what i'm trying to say how do i install this as a component in an existing flex app? can i make the flexfileupload.mxml a component, import the com and assets folders. then what. i could sure use some details...thanks
# Posted By LeeH | 3/6/08 3:15 PM
# Posted By zoloft | 3/12/08 6:16 AM
# Posted By Alex | 3/16/08 4:35 AM
This application rocks! I did have the security problem though. The Security Error 2049, in my case, had nothing to do with the URL name or the backend (Java Servlet). Using an HTML Form worked fine, but not from the Flex app.

Turns out, I was not opening the Flex app from the web server. Because of this, I had to include the crossdomain.xml file. After that, worked like a charm.

The only limitation I see, is that each file uses it's own POST, rather than a single POST. This makes it difficult for me to keep the "grouping" of all the files open, in a single request.

I'll create a work-around, but it does make it more difficult.
# Posted By Aaron Paxson | 3/28/08 10:53 AM
http://humanspiritonline.com Thousands movies in one place.
# Posted By Download movies online | 4/14/08 7:03 AM
Thanks for sharing this Ryan.
http://www.voyance-officielle.fr
# Posted By voyance | 4/22/08 10:12 AM