[Looking for Charlie's main web site?]

CFMythbusters: For a file to be uploaded to CF, the page needs a CFFILE Upload tag, right? Wrong!

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
I was sharing some thoughts on a discussion list and figured others may appreciate the observation.

Have you ever assumed that for a file to be uploaded to CF, in a post to a CFM page, that that page needs a CFFILE Action="upload" in order to "receive" the file? It does NOT. Now, I'm being a bit technical here, but to be clear, the uploaded file will be "received" by CF, if posted to ANY CFM page whether that tag is there or not to "receive it". The point is that this uploaded file will be put in a temp directory, with a temp file name and extension, at least until the end of the request.

What the CFFILE Action="upload" does is just move the uploaded file from a temp directory to your named DESTINATION (as well as validate its type, report the file name, protect against or allow overwrites, and more, if you use the attributes on the tag for those features).

And if you do NOT process it, then that temp file will be removed at the end of the request (unless perhaps the request terminates unexpectedly).

Need proof? Want to learn more? Read on.

[....Continue Reading....]


I had learned from my first efforts with CFFile that it doesn't actually upload the file, it just transfers it from the server's temp directory to the specified directory, or to the application's memory. From what I understand, the file form field just gives a path to the uploaded file in the temp directory.

That said, even though CFFile may not be working as advertised, there are still ways you can upload the file and process the uploaded file using the java.io.String and FileReader classes. Samuel Neff gives a very nice discussion on how to do this on his blog:


Of course this assumes that your shared hosting account allows you to use createObject and java in general.

See you at CFUnited.

# Posted By Larry C. Lyons | 5/9/06 4:24 PM
Larry, thanks, but I wasn't asserting that it wasn't working. I was just explaining, for those who have thought CFFILE did the uploading, that it does not: that (as you say) all it does is the move on the server from temp to intended destination. I was just pointing this out for those who have wondered or want, in the future, a place to point those who would argue otherwise. See you at the conference.
# Posted By Charlie Arehart | 5/9/06 4:43 PM
Copyright ©2020 Charlie Arehart
Carehart Logo
BlogCFC was created by Raymond Camden. This blog is running version 5.005.
(Want to validate the html in this page?)

Managed Hosting Services provided by
Managed Dedicated Hosting