[ Previous ] [ Contents ] [ Index ] [ Next ]

ns_get_multipart_formdata

Overview

Handle the POST action of a form containing one Netscape file widget

Syntax

ns_get_multipart_formdata key fieldId ?formdataSet?

Description

If you have a Tcl script that is handling a POST of a form containing exactly one Netscape 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.

Example

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 "file" $fp
    	close $fp
    	## Process file
    	## return something
    }

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.