Handle the POST action of a form containing one file widget
(Note: This function is obsolete. Use ns_getform, ns_queryget, and ns_queryexists instead.)
ns_get_multipart_formdata conn key fieldId ?formdataSet?
If you have a Tcl script that is handling a POST of a form containing exactly one INPUT TYPE=FILE widget and 0 or more other widgets, you can call ns_get_multipart_formdata instead of ns_conn form. If you call ns_get_multipart_formdata at any other point, it will not work.
The key argument is the key for the file widget.
The fileId argument must be the file ID of a file that is open for write operations. ns_get_multipart_formdata will write the submitted file (from the file widget) to the file specified by fileId.
If you pass a formdataSet into the function, the rest of the form data is dropped into that formdata set.
In the HTML page, the form is defined as:
<form enctype=multipart/form-data method=post action=/foo> <input name=file type=file> </form>
The POST action is handled by the /foo script defined below:
ns_register_proc POST /foo foo proc foo {conn ignore} { set fp [open "/tmp/uploaded_file" w+] ns_get_multipart_formdata $conn "file" $fp close $fp ## Process file ## return something }