This article provides a sample script, written using Active Server Pages and VBScript, to upload images via the HTTP POST method. Instructions on how it can be tailored for use in your Web applications are also included. You will need to set this facility if you would like to be able to upload local images to the server.

Download the ASP Multimedia upload example code: fileUpload.asp.
The source for EditLive multimedia upload scripts can also be found in the SDK_INSTALL/webfolder/uploadscripts/ directory where SDK_INSTALL represents the directory to where the EditLive! SDK is installed.

Defining the Location of the Image Upload Handler Script

The location of the image upload handler script must be defined within the EditLive! configuration file. This setting is configured via the href attribute of the <httpUpload> element of the configuration file. To use this example script, the href attribute should point to the location of this script on the server.

Defining the Location of the Image Upload Directory

This example script uploads images to the directory specified by the imageDir variable. In order for images to function correctly within EditLive!, the base attribute of the <httpUpload> configuration file element must reflect the location of the directory where images on the Web server.

Example Image Upload Handler Script

Tiny has written a sample image upload handler script using Active Server Pages and VBScript. This script can be found at SDK_INSTALL\webfolder\uploadscripts\asp\fileUpload.asp, where SDK_INSTALL represents the location where the EditLive! SDK is installed.

Below are the steps required to use the ASP image upload handler in your own Web application.

  1. One line of code in the fileUpload.asp file must be changed for image upload.
    • This line of code specifies the location where you want to upload image files. If the location of the upload acceptor script was http://www.yourserver.com/scripts/fileUpload.asp then setting the imageDir variable to ../images would upload the images to a directory with the URL http://www.yourserver.com/images/.

      Dim imageDir
      imageDir="../images"

      Relative paths specified within the image upload acceptor script are relative to the Web accessible location of the image upload acceptor script.

  2. The EditLive! configuration file should now be edited to reflect the changes made in the previous step. You will find these settings within the <httpUpload> configuration file element. The URL setting should reflect the location of the fileUpload.aspfile on your Web server.
    • The following example reflects the setting of the href attribute of the <httpUpload> configuration file element if the upload script is at the URL http://www.yourserver.com/scripts/fileUpload.asp.

       
      <editLive>
         ...
         <mediaSettings>
            <httpUpload
               base=...
               href="http://www.yourserver.com/scripts/fileUpload.asp"/>
            ...
         </mediaSettings>
         ...
      </editLive>
      
  3. Finally, the HTTP Image Upload baseattribute should be changed to reflect the location where images can be found on your Web server.

    This location may not be the same value as that used within the upload acceptor script above. Rather, it will be the virtual directory alias used by your Web server for the location listed in the upload acceptor script.

    • The following example reflects the setting of the href attribute of the <httpUpload> element if the upload script is at the URL http://www.yourserver.com/scripts/fileUpload.asp.

      <editLive>
         ...
         <mediaSettings>
            <httpUpload
               base="http://www.yourserver.com/images/"
               href="http://www.yourserver.com/scripts/fileUpload.asp"/>
         </mediaSettings>
         ...
      </editLive>
      

Extending the Image Upload Script for Use with Other File Types

The ASP upload acceptor script provided with EditLive! can, by default, only be used with common image file types. This is restricted by inspecting the extension of an uploaded file. Support for other file types, including multimedia object types such as Macromedia Flash (.swf) and Apple QuickTime (.mov), can easily be added by adding the relevant extension to the list of allowed extensions in the upload acceptor script.

The list of permitted extensions can be found at the bottom of the ASP upload acceptor script file in the following statement:

 
if OnlyExtention="jpeg" or _
  OnlyExtention="jpg" or _
  OnlyExtention="tiff" or _
  OnlyExtention="png" or _
  OnlyExtention="gif" then
    call SaveFile(curDir & "\" & OnlyFileName, FileData)
end if

The example below demonstrates how this example can be extended to handle Flash and QuickTime files:

 
if OnlyExtention="jpeg" or _
  OnlyExtention="jpg" or _
  OnlyExtention="tiff" or _
  OnlyExtention="png" or _
  OnlyExtention="gif" or _
  OnlyExtention="swf" or _
  OnlyExtention="mov" or _ then
    call SaveFile(curDir & "\" & OnlyFileName, FileData)
end if

See Also

Attachments:

fileUpload.asp (application/octet-stream)
fileUpload.asp (application/octet-stream)
fileUpload.asp (application/octet-stream)