back File Upload

Most browsers support file upload using the RFC-1867 specification. This allows files to be encoded using multipart/mime and submitted using the HTTP POST method. Web servers supporting file upload should decode the files and store them locally before allowing CGI, PHP, ESP or equivalent mechanisms to access and manage the uploaded files.

AppWeb supports the file uploadfor browsers that support the RFC-1867 specification. Embedded Server Pages and PHP provide access to the uploaded files. This documentation will focus on ESP access to uploaded files. Consult PHP documentation for access using PHP. Currently the WebServer ESP implementation does not support file upload.

When files are uploaded, they are created in a temporary holding directory on disk. The location of the upload directory is defined by the FileUploadDir configuration directive. For each uploaded file, an object entry in the ESP files[] array will be created. The name of these objects is given by the upload field name in the ESP page. 

upUpload Example

For example, the following HTML page:



File







This HTML fragment will allow a file to be uploaded containing, say a Company's logo. The recieving ESP page could then access the uploaded file.

Local temporary file name : @@files['logoFile'].FILENAME


Client file name : @@files['logoFile'].CLIENT_FILENAME


Size of file : @@files['logoFile'].SIZE




You can also iterate over all elements of the files[] array using the for/in statement. For example:

<%
for (var f in files) {
    write("

Size of " + f + " = " files[f].SIZE);
}
%>


The objects in files[] contain the following properties:
  • CLIENT_FILENAME - Name of the uploaded file given by the client.
  • CONTENT_TYPE - Type of the encoded data.
  • FILENAME - Local name of the temporary file in the upload directory.
  • SIZE - Size of the uploaded file in bytes.


© Mbedthis Software LLC, 2003-2204. All rights reserved. Mbedthis is a trademark of Mbedthis Software LLC.