Why does it matter if the file functions are used (eg fileOpen, fileClose, etc) or if the CFFILE tags are used?
Don't they perform identically?
No - they do not work the same. Unfortunately, there is no fileUpload.
I cannot find a single example of how to use the new functions to perform a file upload. This is the code I have come up with and it works fine - except the doc gets saved with the temp name instead of the 'real' name.
<!--- get file name --->
<cfset originalFileName = GetFileFromPath(FORM.sFile)>
<!--- upload file --->
<!--- instantiate object --->
<cfset fileOb = fileOpen(FORM.sFile, "read")>
<!--- move file from temp directory to final folder --->
<cfset destinationfile = "c:\fileUploads\test\#originalFileName#">
<cfoutput>A copy of #destinationfile# already exists.</cfoutput>
<cfoutput>Copied: #originalFileName# <BR>
<!--- close object --->
<cfset info = getFileInfo("c:\fileUploads\test\#originalFileName#")>
I'm looking into using JS to set a hidden form value with the original name (file upload object defaultValue) but I'm still not particulary proficient at JS and I doubt it is necessary - I must be doing something wrong with these new CF8 file functions.
I cannot find a single example of how to use the new
functions to perform a file upload.
Never mind - I'm a bloody idiot confusing my reads, writes, html functions and ColdFusion.
You gotta love the internet - one's stupidity can never be retracted.
You said that they do not behave identically.
Why would you want to use the CF functions and not the CFFILE tag?
What's the difference other than syntax?
What's the difference other than syntax?
There is not an equivalent function for that for . That is what they really needed here.
The advantage of the functions over cffile is that documents can be read such that you don't have to load the entire document into memory. This avoids server issues, especially if several users are reading large docs simultaneously. It also means that very large (heavy) documents can be read whereas in the past they would error out.
Oh, yes. I misread the question.
I'm not sure that the <cffile action="upload"....> ever read the file into memory. All it really does is an operating system file copy form the temp directory of the web server comibined with a file rename and some other basic house keeping tasks.
I think you are trying to compare the <cffile action-"read"....> which did suffer from the issues you mentioned, with these new functions and the action="upload" is a different beast.
I think you are trying to compare the <cffile
action-"read"....> which did suffer from the issues you
mentioned, with these new functions and the action="upload"
is a different beast.
Yes, you are right about that. I had mentioned something similar to the OP on another forum. I think they are clear on the difference now. I suspect their latest response was just talking about the difference between the tag/function version of "reads".
When I was originally chasing my tail over this issue I somehow got it in my head that CF was involved with the inital data transfer from the browser to the server. It is not and cannot be (what is more fundamental than CF resides on the server). That data (the file) is sent in the http packet.
I have friends from all over the States emailing me and calling me a *******. They are enjoying themselves. I plead temporary insanity.
However, subsequent reads of that data are server related and the CF8 file functions are a superior method of performing them.
Now, if I haven't said anything else moronic, I will go crawl back under my rock...
Thanks for the help guys
I somehow got it in my head that CF was involved with the inital data transfer from the browser to the server.
Don't beat yourself up too much over this, it is a common conception that is addressed on a regular basis on these forums. Often in a response to some request like "I want ColdFusion to tell my users their file is too big before they upload it to the server."
And I can only hope some such future user will find this thread, or another like it, before they post the question again.