$Web Proc Receive or $Web Proc Recv: Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 2: | Line 2: | ||
<span class="pageSubtitle"><section begin="desc" />Receive uploaded file into procedure<section end="desc" /></span> | <span class="pageSubtitle"><section begin="desc" />Receive uploaded file into procedure<section end="desc" /></span> | ||
$Web_Proc_Receive receives file upload data into a procedure. $WEB_PROC_RECV is a synonym for $Web_Proc_Receive. | |||
==Syntax== | ==Syntax== | ||
<p class="syntax"><section begin="syntax" /> %RC = $WEB_PROC_[RECEIVE | RECV]( filename, procname, - | <p class="syntax"><section begin="syntax" /> %RC = $WEB_PROC_[RECEIVE | RECV]( filename, procname, - | ||
Line 10: | Line 9: | ||
p_flag ) | p_flag ) | ||
<section end="syntax" /></p> | <section end="syntax" /></p> | ||
$Web_Proc_Receive is a callable $function (see [[Calling_Sirius_Mods_$functions|Calling Sirius Mods $functions]]). | $Web_Proc_Receive is a callable $function (see [[Calling_Sirius_Mods_$functions|Calling Sirius Mods $functions]]). | ||
Line 16: | Line 14: | ||
$Web_Proc_Receive takes five arguments and returns a status code. | $Web_Proc_Receive takes five arguments and returns a status code. | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>filename | <tr><th>filename | ||
<ul> | <ul> | ||
<li>A name only. | <li>A name only. | ||
<li>Prefixed with "FILE" or "GROUP". | <li>Prefixed with "FILE" or "GROUP". | ||
</ul> | </ul> | ||
</th> | |||
<td>The name of the ''Model 204'' file or group into which the data is to be received. This parameter is optional. If it is not specified, the default file or group is used. This parameter may be specified as either of the following: In this case, "FILE JANWEB" will look for the specified procedure in the file named JANWEB, "GROUP JANWEB" will look for the procedure in the group named JANWEB, and a bare "JANWEB" will look in a group first if it is open, then in a file.</td></tr> | <td>The name of the ''Model 204'' file or group into which the data is to be received. This parameter is optional. If it is not specified, the default file or group is used. This parameter may be specified as either of the following: In this case, "FILE JANWEB" will look for the specified procedure in the file named JANWEB, "GROUP JANWEB" will look for the procedure in the group named JANWEB, and a bare "JANWEB" will look in a group first if it is open, then in a file.</td></tr> | ||
<tr><th>procname</th> | <tr><th>procname</th> | ||
Line 33: | Line 28: | ||
<td>The number of the form field associated with the "<input type=file>" tag in the HTML form. This argument must be 1 or not present if the upload request was the result of an HTTP PUT rather than a form-based upload. On a form-based upload if neither ''fieldname'' nor ''occurrence'' is present, the first (or only) file in the form will be uploaded. If ''occurrence'' is present but ''fieldname'' is not, the ''occurrence'' number file is uploaded regardless of its name. If both ''occurrence'' and ''fieldname'' are present, the ''occurrence'' number file with name ''fieldname'' is uploaded.</td></tr> | <td>The number of the form field associated with the "<input type=file>" tag in the HTML form. This argument must be 1 or not present if the upload request was the result of an HTTP PUT rather than a form-based upload. On a form-based upload if neither ''fieldname'' nor ''occurrence'' is present, the first (or only) file in the form will be uploaded. If ''occurrence'' is present but ''fieldname'' is not, the ''occurrence'' number file is uploaded regardless of its name. If both ''occurrence'' and ''fieldname'' are present, the ''occurrence'' number file with name ''fieldname'' is uploaded.</td></tr> | ||
<tr><th>p_flag</th> | <tr><th>p_flag</th> | ||
<td>Processing indicators for how the server should handle the procedure. This parameter is optional. Valid values are: | |||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>BINARY</th> | <tr><th>BINARY</th> | ||
<td>''[[Janus Web Server]]'' performs no ASCII to EBCDIC translation on the contents and converts the data to the special ''[[Janus Web Server]]'' format binary procedure.</td></tr> | <td>''[[Janus Web Server]]'' performs no ASCII to EBCDIC translation on the contents and converts the data to the special ''[[Janus Web Server]]'' format binary procedure.</td></tr> | ||
Line 43: | Line 37: | ||
<td>''[[Janus Web Server]]'' translates the data from ASCII to EBCDIC, separating the text into records (or lines) at any point where an ASCII carriage return (X'0D') or carriage return and line feed (X'0A') are found. | <td>''[[Janus Web Server]]'' translates the data from ASCII to EBCDIC, separating the text into records (or lines) at any point where an ASCII carriage return (X'0D') or carriage return and line feed (X'0A') are found. | ||
</td></tr></table> | </td></tr></table> | ||
</td></tr></table> | </td></tr></table> | ||
Line 69: | Line 62: | ||
<li>For a form-based upload, the value returned by $Web_Form_Parm for the field associated with the file is the name of the file on the workstation that is being uploaded. | <li>For a form-based upload, the value returned by $Web_Form_Parm for the field associated with the file is the name of the file on the workstation that is being uploaded. | ||
In the following example, a form-based file upload is stored in a procedure with a name of 'UP.' followed by the IP address of the browser followed by the name of the file on the browser. The use of IP address in this case, ensures that different users will not overlay each others files. | In the following example, a form-based file upload is stored in a procedure with a name of 'UP.' followed by the IP address of the browser followed by the name of the file on the browser. The use of IP address in this case, ensures that different users will not overlay each others files. | ||
<p class="code"> %PROCNAME = 'UP.' WITH - $Web_IPAddr WITH '.' - | <p class="code"> %PROCNAME = 'UP.' WITH - $Web_IPAddr WITH '.' - | ||
WITH $Web_Form_Parm('UPFILE') | WITH $Web_Form_Parm('UPFILE') | ||
Line 74: | Line 68: | ||
%RC = $WEB_PROC_RECV('UPPROC', %PROCNAME) | %RC = $WEB_PROC_RECV('UPPROC', %PROCNAME) | ||
</p> | </p> | ||
Note that even though the field name was specified on the $Web_Form_Parm call (because there were other non-file input fields) it was not specified on the $WEB_PROC_RECV call (because there was only one file input field). | Note that even though the field name was specified on the $Web_Form_Parm call (because there were other non-file input fields) it was not specified on the $WEB_PROC_RECV call (because there was only one file input field). | ||
Line 83: | Line 76: | ||
It is quite possible that an HTTP/HTML standards-compliant browser will simply not upload a "type=file" field at all if the end-user did not select a file to be uploaded. In this latter case, a $WEB_PROC_RECV would return a 0, but a $Web_Form_Parm for the "type=file" field would still return a null. | It is quite possible that an HTTP/HTML standards-compliant browser will simply not upload a "type=file" field at all if the end-user did not select a file to be uploaded. In this latter case, a $WEB_PROC_RECV would return a 0, but a $Web_Form_Parm for the "type=file" field would still return a null. | ||
<li>Since the file data you upload is less likely to be encoded as text, you can use code like the following to make your $WEB_PROC_RECV more versatile: | <li>Since the file data you upload is less likely to be encoded as text, you can use code like the following to make your $WEB_PROC_RECV more versatile: | ||
<p class="code"> %FORMAT = 'BASE64' | <p class="code"> %FORMAT = 'BASE64' | ||
%SUFFIX = $ParseX(%PROC,'.') | %SUFFIX = $ParseX(%PROC,'.') |
Revision as of 21:17, 22 February 2011
<section begin="desc" />Receive uploaded file into procedure<section end="desc" />
$Web_Proc_Receive receives file upload data into a procedure. $WEB_PROC_RECV is a synonym for $Web_Proc_Receive.
Syntax
<section begin="syntax" /> %RC = $WEB_PROC_[RECEIVE | RECV]( filename, procname, - fieldname, occurrence, - p_flag ) <section end="syntax" />
$Web_Proc_Receive is a callable $function (see Calling Sirius Mods $functions).
$Web_Proc_Receive takes five arguments and returns a status code.
filename
|
The name of the Model 204 file or group into which the data is to be received. This parameter is optional. If it is not specified, the default file or group is used. This parameter may be specified as either of the following: In this case, "FILE JANWEB" will look for the specified procedure in the file named JANWEB, "GROUP JANWEB" will look for the procedure in the group named JANWEB, and a bare "JANWEB" will look in a group first if it is open, then in a file. | ||||||
---|---|---|---|---|---|---|---|
procname | The name of the Model 204 procedure into which data will be received. If the procedure does not exist, it will be created. If it already exists, it will be replaced. This parameter is required. | ||||||
fieldname | The name of the form field associated with the "<input type=file>" tag in the HTML form, that is, the value of the "name" parameter in that tag. This argument cannot be present if the upload request was the result of an HTTP PUT rather than a form-based upload. On a form-based upload if neither fieldname nor occurrence is present, the first (or only) file in the form will be uploaded. | ||||||
occurrence | The number of the form field associated with the "<input type=file>" tag in the HTML form. This argument must be 1 or not present if the upload request was the result of an HTTP PUT rather than a form-based upload. On a form-based upload if neither fieldname nor occurrence is present, the first (or only) file in the form will be uploaded. If occurrence is present but fieldname is not, the occurrence number file is uploaded regardless of its name. If both occurrence and fieldname are present, the occurrence number file with name fieldname is uploaded. | ||||||
p_flag | Processing indicators for how the server should handle the procedure. This parameter is optional. Valid values are:
|
Code | Meaning |
---|---|
1 | Procedure successfully received. |
0 | Form field not found. |
-1 | Not a web thread |
Usage notes:
- $Web_Proc_Receive does not close the connection with the browser and does not send any response to the browser. It is the responsibility of the User Language programmer to ensure that an appropriate $Web_Done is sent to end the request.
- When $Web_Proc_Receive receives network data, it is first written to CCATEMP. Once the data is received completely in CCATEMP, it is quickly copied to the procedure file. A termination of the write to CCATEMP does not result in partially written procedure file. The setting of the MAXTEMP parameter of JANUS DEFINE as well as the CCATEMP size itself limit the number of pages an uploaded procedure may occupy.
- For a form-based upload, the value returned by $Web_Form_Parm for the field associated with the file is the name of the file on the workstation that is being uploaded.
In the following example, a form-based file upload is stored in a procedure with a name of 'UP.' followed by the IP address of the browser followed by the name of the file on the browser. The use of IP address in this case, ensures that different users will not overlay each others files.
%PROCNAME = 'UP.' WITH - $Web_IPAddr WITH '.' - WITH $Web_Form_Parm('UPFILE') %RC = $WEB_PROC_RECV('UPPROC', %PROCNAME)
Note that even though the field name was specified on the $Web_Form_Parm call (because there were other non-file input fields) it was not specified on the $WEB_PROC_RECV call (because there was only one file input field).
- It appears that most browser implementations of form-based uploads send the "type=file" fields whether or not the end-user selected a file to be uploaded. Because of this, $WEB_PROC_RECV will always return a 1 with these browsers if the indicated field appeared on the form being posted. The way to distinguish the case where a user selected no file from the case where the user selected an empty file is to check if the value of the form parameter associated with the "type=file" field is null. If it is null, it probably means that the user has not selected a file to be uploaded. If it is not null but the target proc is empty after the $WEB_PROC_RECV, it probably means that the user uploaded an empty file. It is quite possible that an HTTP/HTML standards-compliant browser will simply not upload a "type=file" field at all if the end-user did not select a file to be uploaded. In this latter case, a $WEB_PROC_RECV would return a 0, but a $Web_Form_Parm for the "type=file" field would still return a null.
- Since the file data you upload is less likely to be encoded as text, you can use code like the following to make your $WEB_PROC_RECV more versatile:
%FORMAT = 'BASE64' %SUFFIX = $ParseX(%PROC,'.') IF $ONEOF(%SUFFIX, 'TXT/HTML/HTM/JAVA/JAV/RTF/CSV/DIF/- EPS/INC/PL/DB/CGI/CSS/XML/DTD','/') THEN %FORMAT = 'TEXT' END IF ... %RC = $WEB_PROC_RECV(%FGNAME, %PROC, 'source',, %FORMAT)
- See also $Web_Line.