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

cffileupload not actually uploading anything

Contributor ,
Jan 11, 2010 Jan 11, 2010

Copy link to clipboard

Copied

I am using a simple example trying to start experimenting with the multiple file upload feature in CF 9. However it acts like it uploads, gives no sort of error I can see, yet it actually uploads nothing to the server. Am i missing something obvious?

Uploading page code.

  <cffileupload
    align="center"
    url="uploadFiles.cfm"
    width=600/>

Code for the uploadFiles.cfm page.

<cffile action="upload" destination="c:\temp" nameconflict="makeunique" />

Pretty simple code yet it doesn't seem to work. I know I can use cffile to write to the directory as I have tested that seperately. Any ideas out there?

TOPICS
Advanced techniques

Views

5.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

correct answers 1 Correct answer

LEGEND , Jan 12, 2010 Jan 12, 2010

Is there any chance an Application.cfm / .cfc is doing [something] that is getting in the road here?  Can you remove all doubt by sticking a blank Application.cfm in the same dir as your test code?

I'm pretty much out of sensible things to suggest, so looking at some less sensible ones.

What version of Flash Player are you running?  Have you tested this on various different browsers, in case your FP install is bung on the one you're testing with?

--

Adam

Message was edited by: A Cameron

Votes

Translate

Translate
Community Expert ,
Jan 11, 2010 Jan 11, 2010

Copy link to clipboard

Copied

action="uploadAll"

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
Contributor ,
Jan 11, 2010 Jan 11, 2010

Copy link to clipboard

Copied

That doesn't make any difference

From everything I have read cffileupload sends each file individually to the url property indicated. So choosing uploadAll or upload doesn't make a difference. uploadAll is for use when your just posting to a cffile from a normal html form with multiple type="file" fields.

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
Community Expert ,
Jan 11, 2010 Jan 11, 2010

Copy link to clipboard

Copied

You must be doing something wrong. You should also note that cffileupload and <cffile action="uploadAll"> were actually designed to work together to make multiple uploading easier.

I copied your code exactly -- and it works! My file structure is

/uploadTest/uploadAllFiles.cfm

<cffileupload
     align="center"
     url="processUpload.cfm"
     width=600/>

/uploadTest/processUpload.cfm

<cffile action="uploadAll" destination="c:\temp" nameconflict="makeunique" />

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

You should also note that cffileupload and <cffile action="uploadAll"> were actually designed to work together to make multiple uploading easier.

This is incorrect.  Hedge's previous comment is correct.  <cffileupload> calls the action page separately for each file uploaded, so uploadAll - whilst it will work - is not going to get you anything that a simple <cffile action="upload"> will.

--

Adam

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
Community Expert ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

> This is incorrect.  Hedge's previous comment is correct. 
> <cffileupload> calls the action page separately for each file uploaded,
> so uploadAll - whilst it will work - is not going to get you
> anything that a simple <cffile action="upload"> will.

This seems like someone spoiling for an argument. What you say has no relevance to what I said, let alone contradict it.

1) Here are some extracts from the official documentation on cffileupload:

- Displays a dialog for uploading multiple files from the user's system.

- Use this tag to create a SWF file-based file upload control that lets a user upload multiple files to a server.

- To upload files to the server, define a server-side template. The template that you define reads the upload request and uploads the selected files to the server.

- This example sends user-specified files to the server-side template - uploadfiles.cfm. The template file that you define can use the "upload" or "uploadall" action defined in the cffile tag.

- Use the destination attribute in the cffile tag to define the location to save the files. For the uploadfiles.cfm code, see cffile action = "uploadAll".

2) Here are some extracts from the official documentation on cffile action="uploadAll":

- Unlike cffile action="upload", which uploads only one file at a time cffile action="uploadall" uploads multiple files thereby eliminating the need to code multiple cffile action="upload" statements.

- Use this tag in the page specified by the action attribute of a cffileupload control. This tag uploads save the files that the cffileupload control sends when the user clicks the Save File button.

3) Here is what I said, once again:

"You should also note that cffileupload and <cffile action="uploadAll"> were actually designed to work together to make multiple uploading easier."

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

No, not spoiling for an argument (and, sorry, wouldn't bother with you if I was... it would seem... err... "uncharitable" shall we say), just eager to prevent too much dissemination of useless information.

The docs are wrong. They're based on how <cffileupload> worked in early pre-release versions of CF9; this changed before release (I probably broke an NDA when I said that.  Oh well).

Like I said: the action page is called for each file being uploaded.  If you upload four files, the action page is called four times.  Once for each file.  So there is only one file being uploaded per call to the action page.  So using uploadall will work, but in this case "all" is just a single file, so there's no point to using it over simply using "upload".  It'll work, sure, but it's unnecessary and - to me anyway - the lesser of the two options.   You're incorrect to suggest it needs to be "uploadall", or that there's any benefit in doing so.  Accordingly you were incorrect to imply to Hedge that using uploadall was somehow something to do with their problem.

3) Here is what I said, once again:

"You should also note that cffileupload and <cffile action="uploadAll"> were actually designed to work together to make multiple uploading easier."

You can repeat it all you like.  It still doesn't make it accurate.  Or relevant to this situation.

This is easy for you to demonstrate to yourself by using Hedge's code with either upload or uploadall in the action code.  Both work.  Or... in Hedge's case... neither work 😞

--

Adam

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
Community Expert ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

The docs are wrong. They're based on how <cffileupload> worked in early pre-release versions of CF9; this changed before release (I probably broke an NDA when I said that.  Oh well).

I'll take your word for it that the behaviour of <cffileupload> has changed between pre-release and release, and that the documentation needs updating. However, what that amounts to is that, if you want to upload multiple files, either tag combination [<cffileupload>,<cffile action="upload">] or  [<cffileupload>,<cffile action="uploadAll">] will do.

Still, that doesn't make what I said "incorrect", "inaccurate" or equivalent to "the dissemination of useless information", to quote you. Your logic doesn't quite hold. The only way for you to argue that my statement, "cffileupload and <cffile action="uploadAll"> were actually designed to work together to make multiple uploading easier", is incorrect is to demonstrate that the opposite is true.

You haven't done that. All you do is show that <cffile action="upload"> can upload multiple files as well. I didn't disagree with that.

To be clear, it can indeed be that <cffile action="upload"> will download multiple files. (I will verify it myself in a moment). What I find wrong is your argumentation.

Suppose X is designed to accomplish a task, T, and Y, too. Then the statement, "X was designed to accomplish task T", remains correct, although it omits Y. You seem to think the omission implies incorrectness or inaccuracy.

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

You don't seem to get that there is no multiple file upload going on here.  Each file is uploaded separately.  It's not that <cffile action="upload"> can upload multiple files - it can't - it's just that there isn't multiple files to upload.  <cffileupload> does not send a bunch of files which get uploaded all at once via a single request, it sends each file separately, one at time.  So if there are four files to upload, there are four requests made back to the CF server, and the action page is called four times. For each call of the action page, there is only a single file to upload.

So using functionality which is designed for multiple file uploads - in this case - is bad advice because there isn't a requirement for multiple files to be uploaded at once.  It's also bad advice because it's got nothing to do with the problem.  And couldn't possibly have anything to do with the problem.

<cffile action="uploadall"> is for when one has an HTML form which has multiple file inputs.  That's what it's for.  It's not for <cffileupload>.  It doesn't matter what the docs say: the docs are wrong.

It's kinda the same as if someone said <cfoutput>#mySingleRowQuery.myColumn#</cfoutput> doesn't work (for whatever reason), and you say "you need to use <cfoutput query="mySingleRowQuery">#myColumn#</cfoutput>".  Whilst that suggestion will work, it's bad advice because it's both a poor approach, and not actually going to be anything to do with the solution to the problem.

Do you get it?

Too bad if you don't: I give up.

--

Adam

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
Community Expert ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

You don't seem to get that there is no multiple file upload going on here. Each file is uploaded separately.  It's not that <cffile action="upload"> can upload multiple files - it can't - it's just that there isn't multiple files to upload. 

... etc. etc

<cffile action="uploadall"> is for when one has an HTML form which has multiple file inputs.  That's what it's for.

etc. etc.

You too have used the word multiple in the two cases. First case, all files at once; second case sequential upload. Like you and like the poster I know the uploads occur sequentially, not all at once.

Hence, I meant the second case. Multiple doesn't necessarily mean all at once, does it? Go back and read my text, and you will find no suggestion of the first case. Why do you then presume I meant the first case? So that you can create the platform to say I am "incorrect" "inaccurate" and so forth? You have a habit of doing that in these forums. Then you fall silent and play dead when you are corrected.

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
Community Expert ,
Jan 13, 2010 Jan 13, 2010

Copy link to clipboard

Copied

LATEST
<cffile action="uploadall"> is for when one has an HTML form which has multiple file inputs.  That's what it's for.  It's not for <cffileupload>.  It doesn't matter what the docs say: the docs are wrong.

Have you stopped to think that:

1) <cffileupload> might have been designed for convenience, to simulate "an HTML form which has multiple file inputs"?

2) There is no mistake in the documentation, and there is indeed a bug, but that, contrary to what you think, the bug is actually that the tag combination <cffileupload> and <cffile action="upload"> uploads multiple files instead of just one?

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Your code works OK for me.  This is little help other than to confirm what you're doing should work.

When you say it seems to work, you get the green progress indicators... err... progressing... as the uploads seem to take place?  And you end up with "uploaded n of n file(s)" in the mauin progress bar at the end?

Have you checked the CF & JRun logs to see if they're logging anything?

Possibly write to file a dump of the CFFILE variable in the action page, and have a look if there's anything untoward there?  Is the action-page URL definitely being called once per file uploaded?  Stick a <cflog> entry at the top of it to check (or similar).

--
Adam

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
Contributor ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Yes it shows the upload of each file and tells me it is done. I even have an oncomplete script that spits out the file name to the console aft

er each one is uploaded and that gets fired off too. I tried doing a CFDUMP to a file but that doesn't get written either. I

'll try some more of your suggestions though and get back to you. Thanks for the ideas.


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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Humour me.

Swap the <cffileupload> out for a normal form with a <input type="file"> and try to write that to C:\temp...

--

Adam

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
Contributor ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Happy to.

I tried that and pointed it to the same file that has the cffile code in it and the file uploads just fine. So I know the problem is not with the cffile page. It also created the cfdump file too which it is not doing when I use the cffileupload tag.

If I didn't know any better it acts almost like the fash is doing the progress bar and everything but it is never calling the uploadFiles.cfm page which would be why the cfdump variable is never written to the file either.

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

If I didn't know any better it acts almost like the fash is doing the progress bar and everything but it is never calling the uploadFiles.cfm page which would be why the cfdump variable is never written to the file either.

Yep, that's what I was thinking too.  I tried pointing the URL to a bogus action page, but the progress meter gives a very clear 404 error in that situation.  Equally if I omit the <cffile action="upload"> line from the action page, the progress meter indicates the first upload runs, but it stops there, doesn't fire the upload events nor progresses onto the next file.

So I was not able to mung your code in such a way as to be able to replicate what you're seeing.

Can you check in the [CFUSION]/bin dir and see if the files ended up there (or it might be the [JRUN]/bin dir... can't remember)?  I think that's where uploaded files go if a full path is not specified.  Maybe upload a file with a crazy unique name and search the CF file structure to see if it's being stuck somewhere unexepcted.

It does sound like the files are being uploaded.  Just not to where you want them.


--

Adam

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
Contributor ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Yeah I thought of that earlier. I tried searching the entire server for the file name I uploaded but it came up with no matches.

I also tried what you did just now to see if it would break and when I change the url="some file name that does not exist" I get the status code: 404 message. When i remove the action="upload" from my cffile tag and I try again I get a status code: 500 so this seems to contradict my theory that it is not even calling the file. Question is now what?

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Question is now what?

My idea reservoir is running dry.  Although it was never really very full with this issue, anyhow, I have to concede.  Plus it sounds like you've trod most of the same ground I have been thinking of.

Have you looked at the CF & JRun logs to see if something's failing quietly under the hood?

Will continue to scratch my head in case anything else falls out of it.

--

Adam

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
Contributor ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

I looked in the CF logs in the admin area but see nothing. Where do I find the jrun logs?

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

On a default multi-server install, they're in C:\JRun4\logs.  I never use a standard install, so am not sure what the equivalent location would be in that case.  However the file names are along the lines of:

CFUSION-out.log

CFUSION-event.log

Where CFUSION is the name of the CF instance (well... I guess it'll always be CFUSION on a standard install?  Dunno).

--

Adam

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
Contributor ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Yeah neither of those had any information pertaining to it

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Is there any chance an Application.cfm / .cfc is doing [something] that is getting in the road here?  Can you remove all doubt by sticking a blank Application.cfm in the same dir as your test code?

I'm pretty much out of sensible things to suggest, so looking at some less sensible ones.

What version of Flash Player are you running?  Have you tested this on various different browsers, in case your FP install is bung on the one you're testing with?

--

Adam

Message was edited by: A Cameron

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
Contributor ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Hmm think you may have stumbled onto something here. I commented out all the code on the Application.cfm file in that directory and the file upload works. So I started playing with each line of the Application.cfm page and the include I use for security on the directory is causing the problem.

Here is the code for that file. I encrypt the cookie data but I have removed that from the code below. Basically it checks for the cookies then compares them to the login creidentials in the database and if no match is found it routes them to the login page. So the question is why would this stop the code from working?

<!--- Check to see if these cookies are on the client machine --->
<CFIF NOT IsDefined("COOKIE.Password") AND NOT IsDefined("COOKIE.Email")>
    <CFINCLUDE TEMPLATE="index.cfm">
    <CFABORT>
<CFELSEIF IsDefined("COOKIE.Password") AND IsDefined("COOKIE.Email")>
    <!--- validate the information in the cookies --->
    <CFQUERY DATASOURCE="#APPLICATION.DSN#" NAME="GetAdminAccount">
        SELECT * FROM APass
        WHERE Email = <cfqueryparam value="#COOKIE.Email#" cfsqltype="CF_SQL_VARCHAR" maxlength="150"> AND
        Password = <cfqueryparam value="#COOKIE.Password#" cfsqltype="CF_SQL_VARCHAR" maxlength="50">
    </CFQUERY>
    <!--- if validation fails send them back to the login --->
    <CFIF GetAdminAccount.RecordCount EQ 0>
        <CFINCLUDE TEMPLATE="index.cfm">
        <CFABORT>
    </CFIF>
<CFELSE>
        <CFINCLUDE TEMPLATE="index.cfm">
        <CFABORT>
</CFIF>

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
LEGEND ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

I would guess it's because the request being made by the Flash control is a different client agent from your browser, so it's a different session.  And I'm pretty sure Flash doesn't do "cookies" (don't quote me on that!).  So the request coming in from Flash with the file in it would not have the cookies set, so would get diverted.

The question I have is how come the Flash control isn't reporting a failure, or at least halting when the first file doesn't actually get uploaded?  (just like when commenting out the <cffile> call in the action page... after all, the <cffile> is never being encountered).

For the purposes of your requirements though, the upload action page doesn't need the login credentials, so I would stick a "blocking" Application.cfm file in its dir (possibly isolating it in its own dir first!), and coding it so that it can only be accessed via requests coming in from the Flash upload control.

That should sort your situation out, yes?

--

Adam

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
Contributor ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Yep that works fine. I moved it out of that directory to another directory and it works like a charm. Learn something new everyday I guess

Thanks a lot for the 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
Resources
Documentation