$Web File Content: Difference between revisions
Jump to navigation
Jump to search
(Automatically generated page update) |
mNo edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Retrieve input contents</span> | <span class="pageSubtitle">Retrieve input contents</span> | ||
<var>$Web_File_Content</var> retrieves the "content" of a file that was sent using the <tt>multipart/form-data</tt> format on an HTTP Post. <var>$Web_File_Content</var> returns this content as a longstring. | |||
==Syntax== | ==Syntax== | ||
<p class="syntax"><span class="term">%lstr</span> = <span class="literal">$Web_File_Content</span>( <span class="term">name</span>, <span class="term">occurrence</span>, type ) | <p class="syntax"><span class="term">%lstr</span> = <span class="literal">$Web_File_Content</span>( [<span class="term">name</span>], [<span class="term">occurrence</span>], [<span class="term">type</span>] ) | ||
</p> | </p> | ||
<table class="syntaxTable"> | |||
<tr><th>%lstr</th> | |||
<td>A <var>[[Longstrings|Longstring]]</var> variable for the returned content. | |||
<tr><th>name</th> | <tr><th>name</th> | ||
<td>The name of the form field specified as < | <td>The name of the form field specified as <code><input type="file"...></code> from which content is to be retrieved. This is an optional argument; if it is not specified, all form fields are considered to match the request.</td></tr> | ||
<tr><th>occurrence</th> | <tr><th>occurrence</th> | ||
<td>The occurrence number of the form field specified as < | <td>The occurrence number of the form field specified as <code><input type="file"...></code> that matches the first argument from which content is to be retrieved. This is an optional argument; if it is not specified, content is retrieved from the first form field that matches the <var class="term">name</var> argument.</td></tr> | ||
<tr><th>type</th> | <tr><th>type</th> | ||
<td>A case-independent string set to one of the following: | <td>A case-independent string set to one of the following: | ||
<table class=" | <table class="thJustBold"> | ||
<tr><th>Text</th> | <tr><th>Text</th> | ||
<td>The data is text and is to be translated from ASCII to EBCDIC.</td></tr> | <td>The data is text and is to be translated from ASCII to EBCDIC.</td></tr> | ||
<tr><th>Binary</th> | <tr><th>Binary</th> | ||
<td>The data is to be left unchanged.</td></tr> | <td>The data is to be left unchanged.</td></tr> | ||
<tr><th>TextUtf8</th> | <tr><th>TextUtf8</th> | ||
<td>The data is UTF-8 and is to be converted to EBCDIC: each two-byte UTF-8 sequence is converted to the corresponding ASCII character, which is then translated to EBCDIC using the translation table in effect for the <var class="product">[[Janus Web Server]]</var> connection. | <td>The data is UTF-8 and is to be converted to EBCDIC: each two-byte UTF-8 sequence is converted to the corresponding ASCII character, which is then translated to EBCDIC using the translation table in effect for the <var class="product">[[Janus Web Server]]</var> connection.</td></tr> | ||
</td></tr> | |||
</table> | </table> | ||
<var class="term">type</var> is an optional argument, and it defaults to <var>Binary</var>.</td></tr> | |||
</table> | |||
==Usage notes== | |||
<ul> | |||
<li>Interplay of the <var class="term">name</var> and <var class="term">occurrence</var> arguments: | |||
<ul> | |||
<li>If both field <var class="term">name</var> (argument 1) and field <var class="term">occurrence</var> (argument 2) are set, the indicated occurrence of the indicated field is retrieved. </li> | |||
<li>If the field <var class="term">name</var> is set, and the field <var class="term">occurrence</var> is '''not''', the first occurrence of the indicated field is retrieved. </li> | |||
<li>If the field <var class="term">name</var> is '''not''' set, and the field <var class="term">occurrence</var> is, the indicated field number is retrieved regardless of its name. That is, if occurrence number 4 is requested, the fourth received field is retrieved. </li> | |||
<li>If | |||
< | |||
< | |||
<li | |||
<li>If neither the field <var class="term">name</var> nor the field <var class="term">occurrence</var> is set, the first field is retrieved regardless of its name.</li> | |||
</ul></li> | |||
<li>A null is returned by both of these: | |||
<ul> | <ul> | ||
<li>A request for a field that was not uploaded | <li>A request for a field that was not uploaded </li> | ||
<li>A request for a field that has no file content, because it was not specified as < | <li>A request for a field that has no file content, because it was not specified as <code><input type="file"...></code> on the HTML page, or because the HTML form was not specified with<code>enctype="multipart/form-data"</code> </li> | ||
</ul> | </ul> </li> | ||
< | <li><p class="note"><b>Note:</b> Text data retrieved by <var>$Web_File_Content</var> is not affected by the setting of the <var>JANUS DEFINE</var>, <var>JANUS WEB ON</var>, or <var>$Web_ProcSend</var> parameters <var>CR</var>, <var>LF</var>, or <var>CRLF</var>. But to facilitate subsequent parsing, ASCII carriage returns (X'0D') and linefeeds (X'0A') that a client sends as line-separators are translated by <var>$Web_File_Content</var> to EBCDIC carriage returns (X'0D') and linefeeds (X'25').</p> </li> | ||
Having the file content as a single longstring might be inconvenient for many applications, especially if the data is line-oriented. It is the application's responsibility to parse this longstring using either longstring parsing functions (see | <li>Having the file content as a single longstring might be inconvenient for many applications, especially if the data is line-oriented. It is the application's responsibility to parse this longstring using either longstring parsing functions (see [[Longstrings]]) or <var>Stringlist</var> parsing methods (see [[List of Stringlist methods]] — the <var>Stringlist</var> class <var>ParseLines</var> method is likely to be particularly helpful). </li> | ||
</ul> | |||
< | |||
See also [[$Web_Output_Content]] and [[$Web_Input_Content]] | ==See also== | ||
<var>[[$Web_Output_Content]]</var> and <var>[[$Web_Input_Content]]</var> | |||
[[Category:Janus Web Server $functions|$Web_File_Content]] | [[Category:Janus Web Server $functions|$Web_File_Content]] |
Latest revision as of 19:49, 25 August 2014
Retrieve input contents
$Web_File_Content retrieves the "content" of a file that was sent using the multipart/form-data format on an HTTP Post. $Web_File_Content returns this content as a longstring.
Syntax
%lstr = $Web_File_Content( [name], [occurrence], [type] )
%lstr | A Longstring variable for the returned content. | ||||||
---|---|---|---|---|---|---|---|
name | The name of the form field specified as <input type="file"...> from which content is to be retrieved. This is an optional argument; if it is not specified, all form fields are considered to match the request. | ||||||
occurrence | The occurrence number of the form field specified as <input type="file"...> that matches the first argument from which content is to be retrieved. This is an optional argument; if it is not specified, content is retrieved from the first form field that matches the name argument. | ||||||
type | A case-independent string set to one of the following:
|
Usage notes
- Interplay of the name and occurrence arguments:
- If both field name (argument 1) and field occurrence (argument 2) are set, the indicated occurrence of the indicated field is retrieved.
- If the field name is set, and the field occurrence is not, the first occurrence of the indicated field is retrieved.
- If the field name is not set, and the field occurrence is, the indicated field number is retrieved regardless of its name. That is, if occurrence number 4 is requested, the fourth received field is retrieved.
- If neither the field name nor the field occurrence is set, the first field is retrieved regardless of its name.
- A null is returned by both of these:
- A request for a field that was not uploaded
- A request for a field that has no file content, because it was not specified as
<input type="file"...>
on the HTML page, or because the HTML form was not specified withenctype="multipart/form-data"
Note: Text data retrieved by $Web_File_Content is not affected by the setting of the JANUS DEFINE, JANUS WEB ON, or $Web_ProcSend parameters CR, LF, or CRLF. But to facilitate subsequent parsing, ASCII carriage returns (X'0D') and linefeeds (X'0A') that a client sends as line-separators are translated by $Web_File_Content to EBCDIC carriage returns (X'0D') and linefeeds (X'25').
- Having the file content as a single longstring might be inconvenient for many applications, especially if the data is line-oriented. It is the application's responsibility to parse this longstring using either longstring parsing functions (see Longstrings) or Stringlist parsing methods (see List of Stringlist methods — the Stringlist class ParseLines method is likely to be particularly helpful).