The following figure shows an HTML page that can be used
to upload a single file to the Application Server:
The HTML for performing
the upload might look like this:
<form action="<BrokerURL>" method="post" enctype="multipart/form-data">
<input type="hidden" name="_service" value="<ServiceName>">
<input type="hidden" name="_program" value="<ProgramName>">
<table border="0" cellpadding="5">
<tr>
<th>Choose a file to upload:</th>
<td><input type="file" name="myfile"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
In the previous lines of HTML, you
must replace "<
BrokerURL>" with the path to the
SAS/IntrNet Application Broker. For example,
on Windows, this path is usually
http://YourServer/scripts/broker.exe
, where
YourServer corresponds to the domain name of
your Web server. Similarly, you need to specify the service name and
the program that you want to execute after the file has been uploaded.
You should specify the exact values that are shown for the METHOD
and ENCTYPE attributes of the FORM tag.
The INPUT tag in the previous lines of HTML is used to
create the
Browse button and text entry field
in the previous figure. The appearance of this control might be different
depending on which Web browser you use, but the functionality should
be the same. Clicking the
Browse button enables
you to navigate to the file that you want to upload. You can choose
any file that you have access to. This example uses the file
readme.txt
, which resides in the Windows directory
C:\temp
.
After you select a file
and click
OK, all form data is sent to the
Application Broker, which in turn, forwards the data to the Application
Server. As a result, the following SAS macro variables are created:
|
|
|
|
|
Specifies the size of
the uploaded file in bytes (supplied automatically by the Web browser).
|
|
|
Specifies the content
type that corresponds to the uploaded file (supplied automatically
by the Web browser).
|
|
|
Specifies the number
of files that were uploaded.
|
|
|
Specifies the extension
of the file that was uploaded.
|
|
|
Specifies the name and
original location of the file that was uploaded.
|
|
|
Specifies the SAS FILEREF
that you can use to access the uploaded file. This FILEREF is assigned
for you by the SAS server.
|
|
|
Specifies the value
that corresponds to the NAME attribute of the INPUT tag.
|
Your
SAS/IntrNet program
has access to the uploaded file via the FILEREF that is stored in
the value of the _WEBIN_FILEREF macro variable. The following code
example returns the uploaded file to the client:
* Set the Content-type header;
%let RV = %sysfunc(appsrv_header(Content-type, &_WEBIN_CONTENT_TYPE));
* Write the file back to the Web browser;
data _null_;
length data $1;
infile &_WEBIN_FILEREF recfm=n;
file _webout recfm=n;
input data $char1. @@;
put data $char1. @@;
run;
The previous code shows
how to use the _WEBIN_CONTENT_TYPE macro variable to set the content-type
header. The previous code also shows how to use the _WEBIN_FILEREF
macro variable to access the uploaded file.