Page tree

Versions Compared

Key

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

Overview

ASP.NET allows for the easy creation of upload handler scripts. The following ASP.NET page allows files to be uploaded. The fileupload.aspx page does not process the upload, ; this task is performed by the fileupload.aspx.cs page.

Info

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.

...

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> element must reflect the location of the directory where images are to be stored on the Web server.

Example Image Upload Handler Script

Ephox 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\aspnet\fileUpload.aspx and SDK_INSTALL\webfolder\uploadscripts\aspnet\fileUpload.aspx.cs, where SDK_INSTALL represents the location where the EditLive! SDK is installed.

ASP.NET allows for the easy creation of upload handler scripts. The following ASP.NET page allows files to be uploaded. The fileupload.aspx page does not process the upload; this task is performed by the fileupload.aspx.cs page. The code for the fileupload.aspx page is as follows:

Code Block
 
<%@ Page language="c#" Codebehind="fileupload.aspx.cs"
   AutoEventWireup="false" Inherits="Ephox.FileUpload" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
   <HEAD> 
      <title>fileupload</title>
      <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
      <meta content="C#" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5"
         name="vs_targetSchema">
   </HEAD>
   <body MS_POSITIONING="GridLayout">
      <form id="fileupload" method="post" runat="server">
      </form>
   </body>
</HTML>

The POST is then handled in the Page_Load method of the fileupload.aspx.cs page. This appears as follows:

...

  1. One line of code in the fileUpload.aspx.cs file must be changed for image upload.
    • This line of code specifies the location where you wish image files to be uploaded to. If the location of the upload acceptor script was http://www.yourserver.com/scripts/fileUpload.aspx

      _Image Removed

      , then setting the path variable to

      _

      ../images would upload the images to a directory with the URL

      _

      http://www.yourserver.com/images/

      _Image Removed

      .

      Code Block
      string path = "../images";
      Info

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

  2. EditLive!'s configuration file should now be edited to reflect the changes made in the previous step. You will find these settings within the <httpUpload> element. The URL setting should reflect the location of the fileUpload.aspxfile on your Web server.
    • The following example reflects the setting of the href attribute of the <httpUpload> element if the upload script was at the URL

      _

      http://www.yourserver.com/scripts/fileUpload.aspx

      _Image Removed

      .

      Code Block
       
      <editLive>
         ...
         <mediaSettings>
            <httpUpload
               base= ...
               href="http://www.yourserver.com/scripts/fileUpload.aspx" />
            ...
         </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.

    Info

    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.

    • This example follows from the code above. It uses an absolute URL as the value of the base attribute. The value of the base attribute corresponds to the URL that for the directory that images are uploaded to.

      Code Block
       
      <editLive>
         ...
         <mediaSettings>
            <httpImageUpload
               base="http://www.yourserver.com/images/"
               href="http://www.yourserver.com/scripts/fileUpload.aspx" />
            ...
         </mediaSettings>
         ...
      </editLive>
      

...