util_http_file_upload (public, deprecated)
util_http_file_upload [ -file file ] [ -data data ] [ -binary ] \
[ -filename filename ] [ -name name ] [ -mime_type mime_type ] \
[ -mode mode ] [ -rqset rqset ] url [ formvars ] [ timeout ] \
[ depth ] [ http_referer ]Defined in packages/acs-tcl/tcl/deprecated-procs.tcl
Deprecated. Invoking this procedure generates a warning.
Implement client-side HTTP file uploads as multipart/form-data as per RFC 1867.
Similar to util_httppost, but enhanced to be able to upload a file as multipart/form-data. Also useful for posting to forms that require their input to be encoded as multipart/form-data instead of as application/x-www-form-urlencoded.
The switches -file /path/to/file and -data $raw_data are mutually exclusive. You can specify one or the other, but not both. NOTE: it is perfectly valid to not specify either, in which case no file is uploaded, but form variables are encoded using multipart/form-data instead of the usual encoding (as noted above).
If you specify either -file or -data you must supply a value for -name, which is the name of the <INPUT TYPE="file" NAME="..."> form tag.
Specify the -binary switch if the file (or data) needs to be base-64 encoded. Not all servers seem to be able to handle this. (For example, http://mol-stage.usps.com/mml.adp, which expects to receive an XML file doesn't seem to grok any kind of Content-Transfer-Encoding.)
If you specify -file then -filename is optional (it can be inferred from the name of the file). However, if you specify -data then it is mandatory.
If -mime_type is not specified then ns_guesstype is used to try and find a mime type based on the filename. If ns_guesstype returns */* the generic value of application/octet-stream will be used.
Any form variables may be specified in one of four formats:
- array (list of key value pairs like what [array get] returns)
- formvars (list of url encoded formvars, i.e. foo=bar&x=1)
- ns_set (an ns_set containing key/value pairs)
- vars (a list of Tcl vars to grab from the calling environment)
-rqset specifies an ns_set of extra headers to send to the server when doing the POST.
timeout, depth, and http_referer are optional, and are included as optional positional variables in the same order they are used in util_httppost. NOTE: util_http_file_upload does not (currently) follow any redirects, so depth is superfluous.
- Switches:
- -file (optional)
- -data (optional)
- -binary (optional, boolean)
- -filename (optional)
- -name (optional)
- -mime_type (optional, defaults to
"*/*")- -mode (optional, defaults to
"formvars")- -rqset (optional)
- Parameters:
- url (required)
- formvars (optional)
- timeout (optional, defaults to
"30")- depth (optional, defaults to
"10")- http_referer (optional)
- Author:
- Michael A. Cleverly <michael@cleverly.com>
- Created:
- 3 September 2002
- See Also:
- Testcases:
- No testcase defined.