6 Replies Latest reply on Nov 6, 2006 11:52 PM by Nightfall_Blue

    Uploading images : how

      Hi, I';m trying to put together a form that lets me upload a file (an image specifically). I'm using the fusebox framework but that shouldt make a difference. I've done this before, once, and it didnt then. Sadly I no longer have the code.

      I get this error

      The form field "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp10795.tmp" did not contain a file.

      Now according to the CFMX7 WACK using #getDirectoryFromPath(getBaseTemplatePath())# should put it int he same directory as the template. But obviously it doesnt.

      Does anyone have any ideas why this doesnt work????

        • 1. Re: Uploading images : how
          Level 7
          ACCEPT="image/gif, image/jpeg, image/jpg, image/pjpeg" >

          NO pounds or "form." in the filefield parameter. It is resolving
          form.fileName and expecting to get a form field name for a value.

          ACCEPT="image/gif, image/jpeg, image/jpg, image/pjpeg" >
          • 2. Uploading images : how
            Nightfall_Blue Level 1
            Thanks. Thats changed it a little

            I now get the same error but with at least the filename included

            The destination "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\http:\ 0\blanksystem\images\storyimages\484010_business_man_modified[1].jpg" specified in the CFFILE tag is invalid.

            Where is it getting all this "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\" crap from?
            • 3. Uploading images : how
              Nightfall_Blue Level 1
              By a process of elimination I have commented out parts of the code on the action page to discover that the filename is a problem, causing this error while executing the query.

              "String or binary data would be truncated."

              I get this error now and again and its usually easy to solve. What am I missing!!

              WHen I output the filename variable thus


              I get

              • 4. Re: Uploading images : how
                Level 7

                That is the file where the webserver put the file uploaded from the
                client. This is what coldfusion needs to move the file to a location of
                your choosing.

                When uploading a file, coldfusion does not read from the client machine,
                that would be a huge security hole. The process goes like this.

                User submits form with completed file input field.

                Browser retrieves selected file and sends to server as part of the
                request response, (thus the multipart/form-data parameter of the form).

                Web server (IIS|Apache|ect) parse the file data out of the response
                header and saves it in a temporary file, such as the one described above.

                Web server hands off handle of this temp file to application server, in
                our case Cold Fusion.

                ColdFusion follows the directions of the <cffile ...> tag to copy this
                temporary file to a permanent location.
                • 5. Uploading images : how
                  Nightfall_Blue Level 1
                  OK Thanks.

                  I have the cfflie uploading the image to the correct folder. but I need the name of the file that has just been uploaded (ie man.jpg)
                  to update the database with

                  But when I output FORM.FileName

                  I get


                  Surely it should be the name of the file. If not, how do I get the filename value to save in my database so I can use it later?
                  • 6. Re: Uploading images : how
                    Nightfall_Blue Level 1
                    Ahhh... got it working.

                    When I upload the file the string truncated error was because the path was longer than the space it was trying to write it into in the db. It was trying to write the old, client side file path. when I needed to use #cffile.clientfile# as the filename value int he insert query.