File: tapi-c98.htm

package info (click to toggle)
aolserver 3.4.2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 22,692 kB
  • ctags: 33,612
  • sloc: ansic: 171,340; tcl: 10,218; sh: 3,821; cpp: 2,779; makefile: 2,041; yacc: 1,648; perl: 456; php: 13
file content (122 lines) | stat: -rw-r--r-- 5,155 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<HTML><HEAD>
<TITLE>Tcl API Reference -- ns_queryget</TITLE>
<LINK rel=Previous href="tapi-c97.htm">
<LINK rel=ToC href="toc.htm">
<LINK rel=Index href="master.htm">
<LINK rel=Next href="tapi-c99.htm">
</HEAD><BODY BGCOLOR="#ffffff"><A NAME="topofpage"></A>
<TABLE WIDTH=100%>
  <TR>
    <TD ALIGN=LEFT>
      <A NAME="topofpage"></A> <IMG  SRC="as-c-sm.gif">
    </TD>
    <TD ALIGN=RIGHT>
      <A href="tapi-c97.htm"><IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
      <A href=toc.htm> <IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
      <A href=master.htm> <IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
      <A href="tapi-c99.htm"> <IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
      <A name="7983"> </A>
    </TD>
  </TR>
</TABLE>

<a name="191488">
</a><h3>ns_queryget</h3>
<a name="191489">
</a><h4>Overview</h4>
<p><a name="191490">
</a>Get a value from the query data that was part of the HTTP request</p>
<a name="191491">
</a><h4>Syntax</h4>
<p><a name="191492">
</a><b>ns_queryget</b> <i>key</i> ?<i>value</i>?</p>
<a name="191493">
</a><h4>Description</h4>
<p><a name="191494">
</a><b>ns_queryget</b> looks in the query data for the specified <i>key</i>, and returns the value that was included in the HTTP request. If the key does not exist in the query data, "" is returned. The key is interpreted in a case insensitive manner.</p>
<p><a name="191495">
</a>If the optional <i>value</i> argument is specified, and the key does not exist in the query data, the specified value is simply returned. This capability allows for providing a default value if the key doesn't exist.</p>
<p><a name="191496">
</a>This function works for simple forms as well as for multipart formdata.</p>
<p><a name="191497">
</a>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.</p>
<a name="191498">
</a><h4>Examples</h4>
<p><a name="191499">
</a><b>Example 1:</b></p>
<pre>    <a name="191500"></a>set x [ns_queryget name]
</pre><p><p><a name="191501">
</a>If "name" is a key in the query data, the variable x will be set to the value associated with the "name" key. If "name" is not a key in the query data, "" will be returned.</p>
<p><a name="191502">
</a><b>Example 2:</b></p>
<pre>    <a name="191503"></a>set x [ns_queryget name Hoover]
</pre><p><p><a name="191504">
</a>If "name" is a key in the query data, the variable x will be set to the value associated with the "name" key. If "name" is not a key in the query data, "Hoover" will be returned.</p>
<p><a name="191505">
</a><b>Example 3:</b></p>
<p><a name="191506">
</a>Given this HTML form:</p>
<pre>    <a name="191507"></a>&lt;form enctype=multipart/form-data method=POST
    <a name="193458"></a> &nbsp; &nbsp;action=/formtest&gt;
    <a name="191508"></a>Local file: &lt;input name=clientfile type=file&gt;
    <a name="191509"></a>To remote file: &lt;INPUT TYPE=text NAME=path VALUE="" SIZE=80&gt;
    <a name="191510"></a>&lt;input name=submit type=submit value=Upload&gt;
    <a name="191511"></a>&lt;/form&gt;
</pre><p><p><a name="191512">
</a>and this POST handler:</p>
<pre>    <a name="191513"></a>  proc formtest { } {
    <a name="191514"></a>    set remotefile [ns_queryget path]
    <a name="191515"></a>    set localfile [ns_queryget clientfile]
    <a name="191516"></a>    set where_the_data_is [ns_queryget clientfile.tmpfile]
    <a name="191517"></a>  } ;# formtest
</pre><p><p><a name="191518">
</a>Suppose the user specified "spoon.txt" as the Local File and "/oop/ack/tick.txt" as the Remote File, and then submitted the form. The variable values in the formtest procedure will be:<Table Border = "3">
<tr><th><p><a name="193479">
</a><b>Variable</b></p>
<th><p><a name="193485">
</a><b>Value</b></p>

<tr><td><p><a name="193491">
</a>remotefile</p>
<td><p><a name="193497">
</a>"/oop/ack/tick.txt"</p>

<tr><td><p><a name="193503">
</a>localfile</p>
<td><p><a name="193509">
</a>"spoon.txt"</p>

<tr><td><p><a name="193515">
</a>_the_data</p>
<td><p><a name="193521">
</a>something like: "/var/tmp/baaa29444"</p>


</Table></p>
<p><a name="191527">
</a>If you want to use the contents of the uploaded file, you can open it by executing:</p>
<pre>    <a name="191528"></a>  open [ns_queryget clientfile.tmpfile]
</pre><p><p><a name="191529">
</a>You can then read it and manipulate it as you want. Note, however, that this tmp file will be deleted once the connection closes.</p>


<TABLE BORDER="2" CELLPADDING="1" width="100%">
<TR><TD COLSPAN=3><P ALIGN=Center>
<IMG SRC="bluebult.gif">
<A HREF="#topofpage">
<FONT SIZE=-1>Top of Page</FONT></A>
<IMG SRC="bluebult.gif">
</TD></TR>
<TR><TD COLSPAN=3><P ALIGN=Center>
<A href="tapi-c97.htm">
<IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
<A href=toc.htm>
<IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
<A href=master.htm>
<IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
<A href="tapi-c99.htm">
<IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
<BR align=center>
<FONT size=-1>Copyright &copy; 1998-99 America Online,
Inc.</FONT>
</TD></TR></TABLE></BODY></HTML>