12 Replies Latest reply on Dec 9, 2009 12:46 PM by CTek-Media.com

    CF9 Multi File Upload Widget

    CTek-Media.com

      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

        • 1. Re: CF9 Multi File Upload Widget
          SpiderFromMars Level 1

          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?

          • 2. Re: CF9 Multi File Upload Widget
            CTek-Media.com Level 1

            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.

            • 4. Re: CF9 Multi File Upload Widget
              CTek-Media.com Level 1

              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.

              • 5. Re: CF9 Multi File Upload Widget
                SpiderFromMars Level 1

                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?

                • 6. Re: CF9 Multi File Upload Widget
                  -==cfSearching==- Level 4

                  What's the difference other than syntax?

                   

                  There is not an equivalent function for that for . That is what they really needed here.

                  • 7. Re: CF9 Multi File Upload Widget
                    CTek-Media.com Level 1

                    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.

                    • 8. Re: CF9 Multi File Upload Widget
                      -==cfSearching==- Level 4

                      Oh, yes. I misread the question.

                      • 9. Re: CF9 Multi File Upload Widget
                        ilssac Level 5

                        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.

                        • 10. Re: CF9 Multi File Upload Widget
                          -==cfSearching==- Level 4

                          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

                          • 11. Re: CF9 Multi File Upload Widget
                            CTek-Media.com Level 1

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

                            • 12. Re: CF9 Multi File Upload Widget
                              ilssac Level 5

                              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.