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

CF9 Multi File Upload Widget

New Here ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

This new CF9 Multi File Upload widget looks great but it appears it is built using the old CFFILE code rather than that found in the new fileOpen, fileRead etc. functions - the difference being that the latter doesn't load the entire document in memory before writing which avoids several problems.

Am I correct in that this new widget is built on CFFILE 'technology'?

Thanks!

Shane

TOPICS
Advanced techniques

Views

1.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
Participant ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

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?

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 ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

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#">

<cfif FileExists(destinationfile)>
     <cfoutput>A copy of #destinationfile# already exists.</cfoutput>
<cfelse>
     <cfscript>
       FileCopy(originalFileName, destinationfile);
       </cfscript>

       <cfoutput>Copied: #originalFileName# <BR>
       To: #destinationfile#</cfoutput><BR>
</cfif>

<!--- close object --->
<cfset fileClose(fileOb)>


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

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
Valorous Hero ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

I cannot find a single example of how to use the new

functions to perform a file upload. 

http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_uicontrols_02.html

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7388.html

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
Participant ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

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?

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
Valorous Hero ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

What's the difference other than syntax?

There is not an equivalent function for that for . That is what they really needed 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 ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

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.

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
Valorous Hero ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Oh, yes. I misread the question.

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
Valorous Hero ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

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.

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
Valorous Hero ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

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

-Leigh

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 ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Exactly so.

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

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
Valorous Hero ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

LATEST

CTek-Media.com wrote:

Exactly so.

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.

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 ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

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.

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