When Flex 2 came out there was a lot of buzz on how programmer friendly it was. At the time I thought it sounds great but what current problems of mine would it solve. I then came across an article by Ryan Favro titled
Multiple file upload with Flex and ColdFusion. I saw a real problem being solved by Flex and I thought it was a fantastic program. The big problem is at the time I did not know how to use Flex so I could not really customize the component. Fast forward a couple years and I becoming pretty handy with Flex.
The first thing I have decided to release is a mutliple file uploader. The uploader component which I am calling cfmu (I know really original) for the time being should be available in the next couple days. In the meantime I could really use a couple people to test it so drop me a note if you can. The first version of this component will be customizable via a xml settings file. After I get this up and working I plan to build in some runtime css so you can style the whole component via stylesheet. The cool thing for cfers out there not really into Flex you can just drop the cfmu folder in your project root and use the following code.
Here is a quick screen shot of the index test page that comes in the download. I have learned so much creating a bunch of small components like this and the first series will walk you through this component so you can understand how I created it. Also if you have not read the article by Ryan that I linked to above you should really check it out.
This entry was posted on July 31, 2008 at 10:40 AM and has received 5222 views. Comments 33 |
Print this entry.
#1 by Jamie on 7/31/08 - 10:44 AM
#2 by todd sharp on 7/31/08 - 10:44 AM
#3 by Dan Vega on 7/31/08 - 10:47 AM
#4 by Ben Nadel on 7/31/08 - 12:58 PM
#5 by Johan on 8/1/08 - 1:09 AM
Interested in if/how you are handling security between Flex/CF.
Some suggestions (you may have implemented these already):
- allow setting for max file size that can be uploaded
- I assume Remove allows removing multiple files that are selected in grid
- Cancel button that stops upload, useful if you have selected a lot of files and want to terminate uploading
#6 by Dan Vega on 8/1/08 - 9:15 AM
#7 by Jose on 8/1/08 - 10:37 AM
#8 by Dan Vega on 8/1/08 - 10:47 AM
#9 by Johan on 8/1/08 - 4:35 PM
#10 by Dan Vega on 8/1/08 - 4:38 PM
#11 by Adrian Lynch on 8/1/08 - 4:41 PM
cfmu.riaforge.org
Awesome job dude!
#12 by Dan Vega on 8/1/08 - 4:42 PM
#13 by Johans on 8/1/08 - 6:00 PM
#14 by Johan on 8/1/08 - 6:21 PM
Of course if the handler moves files after upload then chances of a user guessing path and trying to execute a file is harder. Also will pay to check file extensions on the server, not just the flex client.
#15 by Johan on 8/1/08 - 6:55 PM
#16 by Johan on 8/1/08 - 6:59 PM
#17 by Johan on 8/1/08 - 7:47 PM
#18 by Dan Vega on 8/1/08 - 9:57 PM
#19 by RyanTJ on 8/5/08 - 1:21 PM
#20 by Dan Vega on 8/6/08 - 1:04 PM
#21 by Johan on 8/6/08 - 6:23 PM
@Dan - another suggestion is that the server could (should?) confirm to the client the upload has in fact completed with the file saved on the server.
For example the UI could display a tick/cross next to each item based on server response or only remove items that upload correctly from the list.
On a different note: it would be nice to consider reducing network traffic/time for uploads. The XStandard editor does this by zipping files and then chunking them into packets. On the server side you count and reassemble the packets and unzip to recover the file. As far as I know there is a ZIP library for AS.
#22 by Johan on 8/11/08 - 8:01 PM
In my test case I login from my Flex app via AMF and then pass "roles" back to the CF methods.
MSIE will pass the cookies set by CF back with file upload (http not AMF) and CF can then tie the upload request to the appropriate cfloginunser session and associated role/s.
However the other browsers will not send the cookie so CF does not link the request to a user session/roles and the CFC authentication fails.
A solution is to pass the j_username and j_password fields with the http request and use cflogin/cfloginuser in say your onRequestStart() method - but it's not nice sending the username/password with each request.
Probably a better solution is to pass a validation key value (made up of the file details and logged in user details value) in a field with the upload and verify that before handling upload.
#23 by Johan on 8/23/08 - 4:55 PM
You can get it to work across all browsers by appending the JSESSIONID value to the URL:
_uploadURL.url = "uploader.cfc&method=upload" + "&jsessionid=" + _sessionID;
To get the value of the JSESSIONID cookie (_sessionID above) I simply pass it back from ColdFusion when the user has logged in.
I tested on MSIE, Firefox, Safari and Opera and works on all.
I also tested using standard CF session to secure the upload and again this worked fine in MSIE but failed in others, so I expect the solution is the same - append the CFID and CFTOKEN cookie values to the URL and then you can use your own session security scheme.
#24 by Bernhard on 11/20/08 - 10:14 AM
I really 'd enjoy CFMU but when I hit "Upload" I get the error #2038. It seems the error occours for each file I selected.
And here a very important suggestion:
Is it possible to make every text like the button texts editable via the settings.xml? It would be very handy if german users get german text.
#25 by Bernhard on 11/20/08 - 10:26 AM
#26 by Dan Vega on 11/20/08 - 1:18 PM
#27 by Bernhard on 11/21/08 - 3:41 AM
thank you very much for your answers. With "reload" I just mean to reload the template that opened/included the cfmu template.
See, I have a file manager. In the directory tree I open the cfmu and upload files. At this time after the upload happens nothing, the new files can't be seen because the template doesn't reload after upload. So it would be nice to give cfmu some action to do after the upload has finished.
BTW: Is there any way to buy or get the source of main.swf?
Greetings, thanks in advance
Bernhard
#28 by Mohammad Asim on 1/29/09 - 3:08 AM
First of all thanks for such a good uploader. I also get errors same as Bernhard, but I found that any change in settings.xml is not accepting by cfmu. Then, clearing browser cache solves this issue.
I agree with Bernhard that there should be a some option for action to do after the upload has finished. Any simple JS call would be helpful, i.e. _root.formSubmit() etc.
Once again, Thanks a lot :)
#29 by Dan B. on 4/23/09 - 3:13 PM
Bug: No matter which entry in the list of selected uploads I have highlighted it always removes the one on the top of the list... a small hindrance.
#30 by Dan Vega on 4/23/09 - 3:17 PM
2nd - I would hardly call mine a successful career! ha - I guess as long as I can help others though that is a big plus and I am having fun doing it!
#31 by Hammergood on 12/15/10 - 8:02 AM
MSIE passes the cookies set by CF to the upload-cfc. So all SESSION Variables are available in the upload function.
However the other browsers will not send the cookie and so there is another session (other cfid/cftoken) than outside. How can I access the SESSION Variables oft the correct SESSION in the upload function of the upload-cfc?
Thanks for helping!
#32 by Hammergood on 12/15/10 - 8:03 AM
MSIE passes the cookies set by CF to the upload-cfc. So all SESSION Variables are available in the upload function.
However the other browsers will not send the cookie and so there is another session (other cfid/cftoken) than outside. How can I access the SESSION Variables oft the correct SESSION in the upload function of the upload-cfc?
Thanks for helping!
#33 by Dan Vega on 1/4/11 - 8:10 AM