Classes

Method Html3():getFile() Professional

![B:0355] Get the content of a file that was uploaded to the WAA server.

Syntax
:getFile( <cFilename> | <cVarName> ) --> cFileContents | NIL
Parameters
<cFilename>
<cFilename> is the filename of the file uploaded to the WAA server.
<cVarName>
<cVarName> is the name of the file uploaded to the WAA server.
Return

The method returns the contents of the file that was uploaded to the server.

Description

Retrieving a file that was uploaded to the WAA server must be accomplished in two steps: first, retrieve the filename using the method :getVar(), then use this method to retrieve the file's contents.

Note that the encoding of the HTML form must have been specified as "multipart/form-data" in order to transfer the file contents.

Code of the HTML form:

<FORM ACTION="/cgi-bin/waa1gate.exe" METHOD=post 
      ENCTYPE="multipart/form-data"> 
  <INPUT TYPE=hidden NAME="WAA_PACKAGE" VALUE="My_Dll"> 
  <INPUT TYPE=hidden NAME="WAA_FORM"    VALUE="My_Function"> 
  <INPUT TYPE=file   NAME="File1"       multiple> 
  <INPUT TYPE=submit VALUE="Caption"> 
</FORM> 

PRG code to retrieve the file's contents:

xFileNames := oHTML:getVar( "File1" ) 

IF "C" == ValType( xFileNames ) 
   xFileNames := {xFileNames} 
ENDIF 

// Successively retrieve the content of each file that 
// was uploaded. Note the "multiple" attribute in the 
// HTML, which allows to select multiple files in the 
// client browser. 
FOR nFileName := 1 TO Len( xFileNames ) 

  cFileName := xFileNames[nFileName] 

  cContents := oHTML:getFile( cFileName ) 

  // Todo: Process the contents of the file 

NEXT 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.