Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
WebSpeed API Reference : get-binary-data
 

get-binary-data

This function returns a MEMPTR to the contents of a file posted from a Web page by a multipart/form-data form. The function uses the GET-BINARY-DATA method of the WEB-CONTEXT system handle.

Location

web\method\cgiutils.i

Parameters

INPUT p_name AS CHARACTER
The name of a field on the form. The field's type must be file.

Returns

MEMPTR

Note

If the uploaded file exceeds the limit set in the binaryUploadMaxSize property, the function returns the Unknown value (?) instead of a MEMPTR.

Example:

/* This example shows how to retrieve the data from a file passed on a given
request, and save it as a file with the same name to the WebSpeed's working
directory. Note that 'filename' is the name of the field in the form posted. */

DEFINE VAR mFile AS MEMPTR NO-UNDO.
DEFINE VAR cfile AS CHAR NO-UNDO.

/* 'filename' refers to the name of the field in the form. get-binary-data
returns the contents of the file associated with the form field named 'filename'. */
ASSIGN mFile = get-binary-data("filename").
IF mFile <> ? THEN DO:
/* if we got a valid pointer, save data to file. The value of the field
'filename' is the file name posted */
ASSIGN cfile = get-value("filename").

COPY-LOB FROM mFile TO FILE cFile NO-CONVERT.

END.