less than 1 minute to read
Retrieves a single file uploaded with HTTP file upload into a binary string.
Use GetMultipartFiles instead
We recommend you use GetMultipartFiles instead of this function to allow retrieving multi-file selections which are common these days.
HTTP file uploads and multipart forms are sent up to server with multipart forms which are submitted in an HTML page as follows:
html
<form action="FileUpload.wwd" method="POST" **enctype="multipart/form-data"**>
<input type="file" name="File" id="File">
<strong>File Description:</strong>
<textarea rows="4" name="txtFileNotes" cols="43"></textarea>
<input type="submit" value="Upload File" name="btnSubmit">
</form>
o.GetMultipartFile(lcKey, @lcFileName)
Return Value
String that contains binary image of the file. Use STRTOFILE() to save the file to disk.
Parameters
lcKey
The name of the file to retrieve
@lcFileName
Optional - a string that will be filled with the file's name. must be passed by reference. Initial value is ignored.
Example
foxpro
lcFileBuffer = Request.GetMultiPartFile("File",@lcFileName)
lcNotes = Request.GetMultipartFormVar("txtFileNotes")
lcFileName = SYS(2023)+"\"+lcFileName
IF LEN(lcFileBuffer) > 5000000
THIS.StandardPage("File upload refused",;
"Files over 500k are not allowed for this sample...<BR>"+;
"File: " + lcFilename)
RETURN
ENDIF
*** Now dump the file to disk
STRTOFILE(lcFilebuffer,lcFileName)
THIS.StandardPage("Thank you for your file upload",;
"<b>File Uploaded:</b> " + lcFileName + ;
" (" + TRANSFORM(FileSize(lcFileName),"9,999,999") + " bytes)<p>"+ ;
"<b>Notes:</b><br>"+ CRLF + lcNotes )
See also:
Class wwRequest | wwRequest::GetMultiPartFiles | wwRequest::Form© West Wind Technologies, 1996-2024 • Updated: 11/29/22
Comment or report problem with topic