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.
Download the ASP.NET Multimedia upload example code: fileUpload.asp.
The POST is then handled in the Page_Load method of the fileupload.aspx.cs page. This appears as follows:
- 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, then setting the path variable to ../images would upload the images to a directory with the URL http://www.yourserver.com/images/.
string path = "../images";
Relative paths specified within the image upload acceptor script are relative to the Web accessible location of the image upload acceptor script.
- 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.
<editLive> ... <mediaSettings> <httpUpload base= ... href="http://www.yourserver.com/scripts/fileUpload.aspx" /> ... </mediaSettings> ... </editLive>
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.
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.
<editLive> ... <mediaSettings> <httpImageUpload base="http://www.yourserver.com/images/" href="http://www.yourserver.com/scripts/fileUpload.aspx" /> ... </mediaSettings> ... </editLive>