CFMU 2 quick updates

Tags: CFMU,Flex,AS3
Word Count: 441

I got some good suggestions as far as additions go and thought I would throw in 2 quick ones in today. The first is being able to set a max file size in the settings file. By default the max file size is 0 and if you don't change it then its up to the flash player to set the limit. If the user tries to upload a file that is greater than the max file size (measured in bytes) they will get an alert telling them they have exceeded the limit. So once you set a file limit how do we implement it? First off we need to look at how the browse process works.

1.) User clicks browse button
2.) onBrowse Event handler method is called
3.) Create a file reference list
4.) Add a Select event listener
5.) Call the file reference list browse method

Once the browse method is called the OS opens the open dialog box.  Once a user selects a file or files the onSelectFile method is called. Now we have to loop through a list of files, if the user only selects one file then we will only do 1 loop. For each iteration we check check to see if the max file size is 0 (default) if so we just add the file to the array collection. If its not we check to see if the size exceeds our limit. If it does we display a friendly error message letting the user know what happened.

The second update was to allow for removing of multiple files which I covered in the  last post

Comments

#1 Posted By: Johan Posted On: 8/1/08 4:51 PM
An alternative approach is to store the name/size of files exceeding the limit in an array and then display a single alert listing all the files otherwise the alert will be popping up for each selected file.
#2 Posted By: Dan Vega Posted On: 8/1/08 4:52 PM |
Author Comment
I actually like that approach better because then you don't have to click ok 15x's
#3 Posted By: Gareth Arch Posted On: 8/1/08 10:44 PM
Rather than showing an Alert with a list of files, why not just change the row color (perhaps to red) of the files with one Alert.show( "Files in red exceed the maximum file size" ); ?
#4 Posted By: Dan Vega Posted On: 8/1/08 10:51 PM |
Author Comment
I like the idea but here is the one problem with that. I don't want it to even get added to the grid because then I have to check again for files that exceed limit when they hit upload.
#5 Posted By: Adrian Lynch Posted On: 8/2/08 9:25 AM
Hey Dan, I've got the movie loading in my page but when I select a file to upload it only shows the extension in the list:

http://www.adrianlynch.co.uk/images/temp/extension...

When I then click Upload I get the following:

http://www.adrianlynch.co.uk/images/temp/error.jpg...

Any idea what I might be doing wrong?

Cheers.
#6 Posted By: Tom Steeper Posted On: 8/25/08 11:34 AM
Is there a way of feeding it a dynamic path for the upload folder? I see it reads an xml file, and the only 2 ways I can think of doing it are:

1. create the xml files on the fly prior to loading the flash file (could run into caching/timing issues).

2. modify the cfc to move the files after upload...but I still need to pass the path which would presumably have to be from a session variable.

Cool stuff by the way. I am very impressed, and have learnt a lot from reading your blogs, especially with me being a recent upgrader from CF5!!
#7 Posted By: Dan Vega Posted On: 8/26/08 9:58 AM |
Author Comment
@Adrian - Are you still having the issue? I am sorry but I did not see your comment until now. It looks as though some path is wrong here. The way I can tell is because the title of the uploader is not showing up.

@Tom - Can you give me an example of what you are trying to do? Are you trying to set up different folders per user or something similar? There may be no way to do that without passing some flash vars in. I can probably just give you the source if you think that will help.
#8 Posted By: Tom Steeper Posted On: 8/26/08 12:44 PM
Hi Dan, Thanks for the response.

I have a backend document management system I am working on. I am currently using a CFTREE to browse/edit folders, but also the ability to upload docs to a chosen folder. I am passing the folder name to the page with CFMU file, and need this parameter for the upload folder.

Flashvars would work just great, though a look at the source would also be beneficial...but I understand why you would be reluctant to do so.

Thanks again for all the information you have posted.

Tom


Post Your Comment







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.