6 Replies Latest reply on Apr 2, 2013 5:09 PM by BreakawayPaul

    Re-size image on upload

    jamie61880 Level 1

      Hi everyone,

         I have created a Blog page on our site and am setting up a page for anyone in the company to update the blog with some text and an image.

         Does anyone know how to set up code so when the Browse button is clicked that it will resize the image automatically to what I want it to be with the pixel size and file size? I’m thinking having it be 200 pixels wide and height doesn't matter. Maybe have the file size at 4K or so. It would be like Facebook when you upload a large file image, but it re-sizes it automatically.

          We have CF version 7, so I can't use the CFimage code that's in 8 and 9. I've found something called imageCFC.resize(), but I don't understand how to use this or incorporate this into my code.


      This is what I have on my pages now just to upload an image file:


      Add Page:

      <td><input type="file" name="Image1" id="Image1"></td>


      Add Action Page:

      <cfif isdefined("form.Image1")>

        <cffile action="upload" filefield="Image1" destination="#ExpandPath("BlogPhotos/")#" nameconflict="overwrite">

        <cfset uploadedfile = "test_file\#file.serverfile#">

      <input name="Blog_Image" type="hidden" value="#file.ServerFile#">




      <cfquery Datasource="#application.DataSource#">

      Insert Into Blog (Blog_Image)


      Values ('#file.ServerFile#')





      I then just display the image on my blog page as an image src file.