File Uploads/Multi-Part Forms |
|
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".
Example:
|
<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.
Example:
!
! Sample Web program to store an uploaded file on the host
! in the /tmp directory
!
! The file is received in the FLNM variable
!
F$=FLNM..FILENAME$
O=pos("/\":F$,-1)
F$="/tmp/"+F$(O+1)
erase F$,err=*next
serial F$
open purge (hfn,isz=-1)F$
write record (lfo)FLNM$
close (lfo)
HTML_FILE$="gotfile.htm"
run "*web/merge"