• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Confused about cffileupload & cffile action="uploadall"

New Here ,
Feb 08, 2011 Feb 08, 2011

Copy link to clipboard

Copied

I'm trying to figure out how to use cffileupload so I have a braindead .cfm file:

<cffileupload 
    url="uploadFiles.cfm"
    progressbar="true"
    name="myupload"
    addButtonLabel = "Add File"
    clearButtonlabel = "Clear All"
    width=600
    height=400
    title = "File Upload"
    maxuploadsize="30"
    extensionfilter="*.jpg, *.png, *.flv, *.txt"
    BGCOLOR="##FFFFFF"
    MAXFILESELECT=10
    UPLOADBUTTONLABEL="Upload now"/>

which is the one from the documentation page. Where I'm losing it is in the processing file.

If the file contains only:

<cffile action="uploadall" destination="c:/testload" nameConflict="overwrite">

the files upload and no problems. The issue is that I want to do additional processing on

each file after it arrives. I've tried this:

<cfoutput>
<cffile action="uploadall" destination="c:/testload" nameConflict="overwrite">

<cfimage source="C:/testload/#CFFile.serverfile#" action="resize" width="300" height="" destination="c:/testload/small.jpg" overwrite="yes">

</cfoutput>

and the CFFILEUPLOAD status bar shows an HTTP 500 error.

Is the uploadFiles.cfm called for each file individually, i.e., if I upload

3 files, is it invoked three times? If so, how do I access the server side file name? If I use

CFFILE.serverFile, I get a HTTP 500 error. Or is this an array or CFFILE structures? I've

tried multiple different approaches and all I get is the HTTP 500 error. None of the examples

I can find explain this or show readable code. Thanks.

Views

4.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 08, 2011 Feb 08, 2011

Copy link to clipboard

Copied

This gave me gray hairs too when I learned this, since the docs on this one suck and blow golf balls through a garden hose.

As you know, CFFILE UPLOADALL handles multiple file uploads at once. But what ColdFusion documentation really frustratingly skips, is explaining to you how things are different when you use the Flash upload control.

> Is the uploadFiles.cfm called for each file individually, i.e., if I upload 3 files, is it invoked three times?

Yes.

What I'd do for debugging is to minimize the processing in the handling template which processes the uploads. Also, make sure the document does not output anything.

Start simply with

<cffile 
    action = "uploadAll"
    destination = "#VIDEO_UPLOAD_FOLDER#"
    nameConflict = "makeUnique"
    result = "myUpload">

>If so, how do I access the server side file name?

As the documentation explains, the upload results are in an array of structures. But wait! *screeeeeech!* As I said, the handling file gets executed once per file. So the array always has a length of one (1).

Thus, after each file uploaded and handled in the background, the server side filename is contained by myUpload[1].serverFile .

My personal approach in applications is to save newly uploaded file information into a database, flagged as not processed yet - then throw the user after the upload to the processing page. For this, the ColdFusion flash file upload control luckily has the oncomplete attribute, which can use a Javascript function to throw you to the next page after an upload.

Hope this helps,

-Fernis

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 09, 2011 Feb 09, 2011

Copy link to clipboard

Copied

Now that's dumb! I thought it would at least create an array

of N elements. The best way would be to have the results

available for a . Oh well, at least now

I know! Thanks for the help!

Steve Haeffele

130 Riviera Dunes Way #1001

Palmetto, FL 34221

Tel: 941-531-7227

Cell: 408-394-3831

Fax: 941-866-2628

e-mail: steve.haeffele@oilartist.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 09, 2011 Feb 09, 2011

Copy link to clipboard

Copied

Fernis,

Well I'm still confused. I wrote a small test just to see if I got it. I still have:

<cffileupload 
    url="uploadFiles.cfm"
    progressbar="true"
    name="myupload"
    addButtonLabel = "Add File"
    clearButtonlabel = "Clear All"
    width=600
    height=400
    title = "File Upload"
    maxuploadsize="30"
    extensionfilter="*.jpg, *.png, *.flv, *.txt"
    BGCOLOR="##FFFFFF"
    MAXFILESELECT=10
    UPLOADBUTTONLABEL="Upload now"/>
</body>

and the uploadFiles.cfm file now contains:

<cfoutput>
<cffile action="uploadall" destination="c:/testload" nameConflict="overwrite" result="myupload">
<cffile action="rename" source="c:/testdir/#myupload[1].serverFile# destination="t#myupload[1].serverFile#">
</cfoutput>

Just to see if I understood your reply. And I'm still getting the HTTP 500 errors.

What am I doing wrong?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 09, 2011 Feb 09, 2011

Copy link to clipboard

Copied

Fernis,

I finally figured it out! Thanks for your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2011 Feb 14, 2011

Copy link to clipboard

Copied

fl_guy,

What was the final issue you had a problem with, and what did you do to resolve it?- I'm having the same issue here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2011 Feb 14, 2011

Copy link to clipboard

Copied

Of all the CF tags I've used, this one is the biggest pain

because when it thows an error, there is very little information

to help you track it down. All that happens is the progress bar

turn red and (in my experience) shows a 500 error. Not terribly

illuminating. The way I was finally able to debug it was to start

at the absolute minimum. The example on the web:

http://www.remotesynthesis.com/post.cfm/multi-file-uploads-with-coldfusion-9

-in-5-lines

is the absolute minimum. I put this into two files, one with the

CFFILEUPLOAD code and the other with the CFFILE UPLOADALL code.

Once I had that working on my testing server, I then began to add

other real code. Again, the challenge is that if you make so much

as one typo (leaving off a # is my bane) in the CFFILE UPLOADALL file, you

get the same red

process bar with a 500 error. So, in the braindead exploration code,

I hard coded the destination, etc., etc., and then started adding to

it.

BTW, another thing that I discovered that may be tripping you up is if

you're

trying to pass parameters on the URL paramter of the CFFILEUPLOAD. You might

want to look at this:

http://www.coldfusioning.com/index.cfm/2009/8/24/cffileupload-Passing-Multip

le-URL-Parameters

Hope this helps! As I said, this tag was a real bear to use but once

you wade through all the black holes, it's pretty neat.

Steve Haeffele

130 Riviera Dunes Way #1001

Palmetto, FL 34221

Tel: 941-531-7227

Cell: 408-394-3831

Fax: 941-866-2628

e-mail: steve.haeffele@oilartist.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2011 Feb 15, 2011

Copy link to clipboard

Copied

Thanks Steve - that was immensely helpful.  Managed to get one problem solved (and create another - what joy!).

😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2011 Feb 15, 2011

Copy link to clipboard

Copied

Glad to be of help. As I said, using this tag is a bear!

Steve Haeffele

130 Riviera Dunes Way #1001

Palmetto, FL 34221

Tel: 941-531-7227

Cell: 408-394-3831

Fax: 941-866-2628

e-mail: steve.haeffele@oilartist.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 25, 2015 Aug 25, 2015

Copy link to clipboard

Copied

LATEST

I was able to get it working without the flash uploader (decided to go away from all UI cf related) and went with the basic input file with multiple. That returned me an array which I was able to parse through and get what I need. What a pain this was! I can't believe the lack documentation on this.

<cffile action="uploadall"
destination="\\#Variables.sServerName#\#filepath#"
nameConflict = "MakeUnique"
result="myUpload">
<cfoutput>
<cfloop from="1" to="#arrayLen(myUpload)#" index="i">
  <cfset data = myUpload>
  <cfloop collection="#data#" item="serverFile">
  <cfif serverFile EQ "serverFile">

  

             do my thing with the newly uploaded filename
 

  

  </cfif>
  </cfloop>
</cfloop>

Thanks guys!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation