| Uploading
Files |
The
Apache HTTP Interface has built in logic to parse
multi-part form transmissions. This makes the process of
having end-users upload files to the host a very simple
process. An upload
page typically will consist of an HTML document
containing a form with an INPUT field whose type is "file".
For example:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;
charset=iso-8859-1">
<title>Upload a picture</title>
</head>
<body>
<form
action="whatever.pvp"
method="post"
enctype="multipart/form-data">
<p
align="center">Enter pathname of the
picture to upload:
<input
type="file" size="32"
name="flnm" id="filename"
accept="image/gif,image/jpg,image/jpeg">
<br>
<input
type="submit" name="command"
value="Upload">
<input
type="submit" name="command"
value="Cancel">
</p>
</form>
</body>
</html> |
When this
page is received by the Apache HTTP Interface, the
variable FLNM$ will be loaded with the
contents of the file submitted by the user. In addition
the fields FLNM..TYPE$ will contain the
file type and FLNM..FILENAME$ will
contain the pathname of the file on the user workstation.
To store the file on the
host simply create a serial file and write the contents
of the variable to the file using Binary IO.
0010 !
0020 ! Sample Web program to store an uploaded
file on the host
0030 ! in the /tmp directory
0040 !
0050 ! The file is received in the FLNM variable
0060 !
0070 LET F$=FLNM..FILENAME$
0080 LET O=POS("/\":F$,-1)
0090 LET F$="/tmp/"+F$(O+1)
0100 ERASE F$,ERR=*NEXT
0110 SERIAL F$
0120 OPEN PURGE (HFN,ISZ=-1)F$
0130 WRITE RECORD (LFO)FLNM$
0140 CLOSE (LFO)
0150 HTML_FILE$="gotfile.htm"
0160 RUN "*web/merge" |
|