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>
<![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:
- DataGrid (this will the datagrid control that will show the file cue)
- Button (this will act as the browse for file button)
- Button (this will clear all files in the cue)
- Button (this will remove a single selected file from the cue)
- Button (this will initiate the upload of cued files)
- Progress Bar ( this will show upload progress)
- String (this string will be the destation of the server side upload script in the example the script is a coldfusion file
- 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)
- 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
UPDATE September, 11 2006
Adobe has just published my new article about this demo to their developer center check it out.

On a side note. Can you do SwA (soap with attachments) with flex/flash?
Very cool example. Keep up the great work!
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.
Just how does one get googed so fast? jeepers, I'm feel so left out of the goog boys club. :( boohoo
DK
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>
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>
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.
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
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
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
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.
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
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.
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...
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.
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
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.
Got a working filemanager now...
I'll send a link when the cms is up and working...
Thanks for all your help!
Johan
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!
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.
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
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.
Thanks a lot for clear me out,
Phuong.
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.
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...
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
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!";
}
?>
----------------------------------------------------------------------
You made my day. Keep up the good work. I'll spread the word.
Greetz,
Nesse
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.
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.
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
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
Walk me through how you got this error to occur. Or send me your code if its easier.
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
Drop into my email ryanfavro[at]newmediateam[dot]com .
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
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
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.
------------------
<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.
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.
any ideas?
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.
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!
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.
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!
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.
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.
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()
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
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.
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.
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"]
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...
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.
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?
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.
<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
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
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.
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.
Chris
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)
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.
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
If anyone got it working in asp.net, can you post the asp.net source. I'm stuck.
Thanks,
Ash
Just one problem. It only works in IE. I get the 2038 error when I run the application in firefox or safari.
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?
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.
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
my email is ryanfavro [at] hotmail [dot] com
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.
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.
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...
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
Thanks a lot dude, your method works.
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
Matt
I'm developing new multi upload class that fits people to extend it and doing their own UI interface etc.
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.
this leads to Application.application.parameters.uploadUrl which is null!
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.
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 ????
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
Thanks for sharing this Ryan.
Has anyone had any luck getting the upload to work over HTTPS using Firefox?
Thanks, 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
Any help would be greatly appreciated.
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
any thoughts?
George
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
thanks
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
Thanks for your file upload concept. It is very much useful for me.
Regards,
Sasi
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 :-(
Any clues?
Any help would be greatly appreciated.
[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2038"]
Thanks.
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.
You deserve a friggin medal. Thank you for saving me hours of headaches. You have made my night. Kudos and good fortune to YOU.
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
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
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?
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>
http://www.netscape.com/member/jennyacomplia
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.
http://www.netscape.com/member/jennyacomplia
http://dionpills.org http://www.divadrugs.com
http://www.ihotmusic.net
http://www.atakamus.com
http://sunpillrx.com
http://www.voyance-officielle.fr