Raymond Camden's Blog Rss

Some notes on CFFILE/UploadAll

6

Posted in ColdFusion | Posted on 11-14-2009 | 4,282 views

Earlier this week I blogged about the new multi-file uploader in ColdFusion 9. While that control handles the front end support for handling multiple uploads, it works hand in hand with a new update to the cffile tag to support multiple file uploads. I did some digging into this and discovered some interesting tidbits.

First - the docs mention that when using cffile/action="uploadall", you get an array of CFFILE structures. This is true - but you will notice that if you use the multi-file uploader that the array will always contain one item. Why? The front end UI control may upload 2 or more files, but it's only going to upload one at a time. In fact, cffile/action="uploadAll" is kind of pointless with that control. It will always only have one upload at a time.

Second - you certainly can use cffile/action="uploadall" without using the new multi-file uploader. You can use it for hard coded forms like so:

view plain print about
1<form action="test3.cfm" enctype="multipart/form-data" method="post">
2<input type="file" name="file1" id="file1"><br/>
3<input type="file" name="file2" id="file2"><br/>
4<input type="file" name="file3" id="file3"><br/>
5<input type="submit" name="submit">
6</form>

In this case, cffile/action="upload" automatically finds all the file fields and processes them in order. Unfortunately you don't get information about the particular form field. The order seems to match the order of the form itself, but I'm not sure that is guaranteed. I'd probably say it is safe to assume it does.

Comments

[Add Comment] [Subscribe to Comments]

It stinks, but it makes sense since Flex will only let you post one file per request. I really wish they'd lift that limitation.
Just to note the downside to the <cffileupload tag like all uses of flash for File Uploading so far it doesn't handle authenticated domains, so for use on intranet's or locked down sites via security it doesn't work as well.
Hey Michael - this is a stretch, but have you ever tried passing the session token to the page that performs the upload? It may trick the server into believing that the Flash request is a normal authenticated user request and allow it to happen. Just a thought - let me know if you're not sure how to do what I'm suggesting.
As of CF9.0 Final, result attribute cannot be in local scope, otherwise the result is a array with 1 null element.

http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbu...
Did you use result="local.foo" or var foo="", result="foo"?
Either one, var first, or inline "local." , same result.

The files got uploaded, but when you dump the result to a file, it'll complain array element 1 is null.

I don't know how what magic scope cffile uploadall uses to keep track of multiple files over multiple requests like how cffileuploader uses.

[Add Comment] [Subscribe to Comments]