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.
Defining the Location of the Image Upload Handler Script
The location of the image upload handler script must be defined within the EditLive! for Java 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! for Java 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 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! for Java 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:
The POST is then handled in the Page_Load method of the fileupload.aspx.cs page. This appears as follows:
Configuring EditLive! for Java to use the Image Upload Script
Below are the steps required to use the ASP.NET image upload handler from above with EditLive! for Java in your own Web application.
1. For image upload, one line of code in the fileUpload.aspx.cs file must be changed.
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 then setting the path variable to ../images would upload the images to a directory with the URL http://www.yourserver.com/images/.
Note: Relative paths specified within the image upload acceptor script are relative to the Web accessible location of the image upload acceptor script.
2. EditLive! for Java'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.aspx file on your Web server.
3. Finally the HTTP Image Upload base attribute should be changed to reflect the location where images can be found on your Web server.
Note: 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 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.
Extending the Image Upload Script for Use with Other File Types
The ASP.NET upload acceptor script provided with EditLive! for Java 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 fileupload.aspx.cs portion of the acceptor script.
The list of permitted extensions can be found as follows in the ASP.NET fileupload.aspx.cs upload acceptor script file in the following statement:
The example below demonstrates how this example can be extended to handle Flash and QuickTime files, note the addition of the file extensions to the if statement in the code below: