Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Creating an Image Upload Handler Script

  1. Use the <CFSETTING> tag to prevent extra whitespace from being written to the output. EditLive! uses all output returned for the saved filename; extra whitespace will cause image URLs to be incorrect. For this reason the <CFSETTING> tag must be the first thing in the document.

    Code Block
     
    <CFSETTING EnableCFOutputOnly="Yes">
    <!--- The above ensures only the <cfoutput> tag causes any output;
          EditLive! includes extra whitespace as part of the file name.
    --->
  2. Create a variable to store the location of the images on the server. In this example, we are using the images subfolder of the script location.

    Code Block
     
    <!---*********************************************
         * Change this line to set the upload folder *
         *********************************************--->
    <cfset uploadFolder="images">
  3. Use the expandPath function to get the full path of the folder on the server.

    Code Block
    <cfset imageFolder=expandPath("#uploadFolder#")>
  4. Save the uploaded file to the images folder.

    Code Block
     
    <!--- Save the uploaded file --->
    <cffile action = "upload"
       fileField = "image"
       destination = "#imageFolder#"
       nameConflict = "MakeUnique">
  5. Return the name of the file to ELJ in case the MakeUnique script directive caused the file to be renamed.

    Code Block
     
    <!--- Notify ELJ of the filename --->
    <cfoutput>#serverFile#</cfoutput>

Example Image Upload Handler Script

Ephox Tiny has written a sample image upload handler script using ColdFusion. This script can be found at SDK_INSTALL\webfolder\uploadscripts\coldfusion\coldfusion_postacceptor.chm, where SDK_INSTALL represents the location where the EditLive!SDK is installed.

...

  1. Open your configuration file in any text editor (e.g. Notepad on Windows).
  2. Locate the <mediaSettings> element and add a <httpUpload> element to it. Only a portion of the full <mediaSettings> element is shown here.

    Code Block
     
    <mediaSettings>
       <httpUpload
          base="images/"
          href="coldfusion_postacceptor.chm">
       </httpUpload>
       ...
    </mediaSettings>
    

...