BBjspWebRequest::getFileUpload (Deprecated)

Description

In BBj 16.0 and higher, this method returns a BBjFileUpload object available in a BBjspWebRequest object.

Syntax

Return Value

Method

BBjFileUpload

getFileUpload(string name)

Parameters

Variable

Description

name

the 'name' of input element from the HTML form

Return Value

returns a BBjFileUpload object

Remarks

The example below demonstrates how to process uploaded files in a BBjspWebRequest and get the associated BBjFileUpload Object by name.

Example

This example demonstrates how this works in a BBJSP web-page

<%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %>

    
        

Hello from BBJSP

You uploaded '${upload["OriginalName"]}' of type: ${uploadFile["ContentType"]} and Size: ${ uploadFile["ContentLength"]} bytes. Please upload a file

This example demonstrates how this works in a BBJSP servlet

class public MyServlet
    field private BBjspWebRequest request!
    field private BBjspWebResponse response!
    field private BBjspWebSession session!

    method public void service(BBjspServletContext context!)

        #request! = context!.getRequest()
        #response! = context!.getResponse()
        resp!.setContentType("text/html")
        s!.write("<html><body><h1>Hello from BBJSP</h1>")
        upload! = #request!.getFileUpload("thefile")
        if (upload! <> null()) then
            declare BBjFileUpload uploadFile!
            uploadFile! = cast(BBjFileUpload,upload!)
            s!.write("You uploaded '")
            s!.write(uploadFile!.getOriginalName())
            s!.write("' of type:"+ uploadFile!.getContentType())
            s!.write(" and Size:")
            s!.write(uploadFile!.getContentLength())
            s!.write("bytes.<br>")
        else
            s!.write("Please upload a file<br>")
            s!.write("<form id="upload" method="post" action="upload" enctype="multipart/form-data">")
            s!.write("<input id="thefile" name="thefile" type="file" /><br>")
            s!.write("<input type="submit" value="submit" id="submit" />")
            s!.write("</br></form>")
        endif
        s!.write("</br></br></body></html>")
    methodend
classend

See Also

BBJSP

BBjspWebRequest

BBjFileUpload