Save a web received file

get_web_file()

Save a file received as a web page parameter


SYNTAX

get_web_file(param_name [, directory[, filename]])

Store the file received as a web page parameter with param_name name into the specified directory (current directory if not specified) and the filename specified (if not specified uses the original sent filename). This function can be used to store documents, images, videos,… received via a web page form.

The function get_web_content_type() can be used to query the received file mime content type.

The function returns 0 (OK) or a negative value to indicate an error. The only possible errors for this function are:

  • WWW_ERR_GENERAL: the parameter name was not found.

  • WWW_ERR_NO_FILE_PARAM: the parameter is not a file parameter.

  • WWW_ERR_FILE_CREATION: The file could not be created


EXAMPLE

An HTML page with a form like this:

<FORM ACTION="getfile.q" ENCTYPE="multipart/form-data" METHOD="POST">
    What file are you sending?
    <INPUT name="paramname" type="file">
    <INPUT VALUE="Send" TYPE="submit">
</FORM>

Then get_web_file (in getfile.r) will save this file (in C:\temp directory):

if (get_web_content_type(paramname, content_type) == WWW_ERR_OK) {
    get_web_file(paramname, "C:\\temp")
}

RELATED TOPICS

Creating web pages with Sculptor

Internet functions

Internet function error codes