ns_queryget - Get a value from the query data that was part of the HTTP request
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
COMMANDS
EXAMPLES
SEE ALSO
KEYWORDS
|
This command looks in the query data for the specified key, and returns the value that was included in the HTTP request. If the key does not exist in the query data, an empty string is returned. The key is interpreted in a case-insensitive manner.
If the optional value argument is specified, and the key does not exist in the query data, the specified value is returned instead of an empty string. This capability allows for providing a default value if the key doesn't exist.
This function works for simple forms as well as for multipart formdata. For files uploaded with the Netscape file upload widget, the file that was uploaded is an entry in the query data. See Example 3, below.
Example 1:
set x [ns_queryget name] |
set x [ns_queryget name Hoover] |
<form enctype=multipart/form-data method=POST
action=/formtest>
Local file: <input name=clientfile type=file>
To remote file: <INPUT TYPE=text NAME=path VALUE="" SIZE=80>
<input name=submit type=submit value=Upload>
</form>
|
proc formtest { } {
set remotefile [ns_queryget path]
set localfile [ns_queryget clientfile]
set where_the_data_is [ns_queryget clientfile.tmpfile]
} ;# formtest
|
localfile = "spoon.txt"
_the_data = something like: "/var/tmp/baaa29444"
|
open [ns_queryget clientfile.tmpfile] |
NOTES Note that despite it's name, ns_queryget works on POST form data as well as query string data.