Get the content type from a file received as a web parameterΒΆ

get_web_content_type()

Retrieve the mime content type from a file received as a web parameter


SYNTAX

get_web_content_type(param_name, field_id)

Store the file mime content type of the specified parameter name into the specified field (it must be an alpha field). The specified parameter must be a file, otherwise an error is returned.

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.

NOTES


EXAMPLE

!include <http.h>

!temp parms,,a50[128]
!temp value,,a50
!temp content_type,,a50
!temp num,,i4
!temp i,,i4

    run report rep1
    exit

!report rep1 {

    !init {
        num = get_web_names(parms)
    }

    !title {
        print "<HTML><HEAD><TITLE>Get all param names</TITLE></HEAD>"
        print "<BODY> There are '"+tostr(num)/"' params:<BR><UL>"
        for (i=1; i<=num; i=i+1) {
            get_web_value(parms[i], value)

            if (get_web_content_type(parms[i], content_type) == WWW_ERR_OK) {
                /* This is a file parameter */
                print "<LI>File Param -> "+parms[i]/": "+value/" (Content-Type: " + content_type/")"
                get_web_file(parms[i], "C:\\temp")
            } else {
                print "<LI>Normal Param -> "+parms[i]/": "+value
            }
            print "</LI>"
        }
        print "</UL></BODY></HTML>"
    }

    print "NOP"
}

RELATED TOPICS

web_content_type()

Creating web pages with Sculptor

Internet functions

Internet function error codes