BBjHttpRequest::getFileUpload (Deprecated)

BBjHttpRequest::getFileUpload is deprecated for BBj 21.00 and higher, and has been replaced by BBxServletRequest::getFileUpload.

Description

In BBj 14.00 and higher, this method returns a BBjFileUpload object available in a BBjHttpRequest object.

Syntax

Return Value

Method

BBjFileUpload

getFileUpload(string name)

Parameters

Parameter

Description

name

Specifies the name of the HTML form field element.

Return Value

Returns aBBjFileUpload.

Remarks

The example below demonstrates how to upload a file to a servlet and get the associated BBjFileUploadObject by name.

Example

rem ' Obtain the instance of the BBjAPI object

let myAPI!=BBjAPI()
MyServlet! = new MyServlet()

data!.setCallback(data!.ON_WEB_CONNECTION, myServlet!, "myMethod")

process_events

class public MyServlet
    method public void myMethod(BBjServletEvent p_event!)
        let chan = UNT
        request! = p_event!.getHttpRequest()
        response! = p_event!.getHttpResponse()
        resp!.setContentType("text/html")
        open(chan)"JSERVLET"
        print(chan)"<html><body><h1>Hello BBj!</h1>"
        upload! = request!.getFileUpload("thefile")
        if (upload! <> null()) then
            declare BBjFileUpload uploadFile!
            uploadFile! = cast(BBjFileUpload,upload!)
            print(chan)"You uploaded '"
            print(chan)uploadFile!.getOriginalName()
            print(chan)"' of type:"+ uploadFile!.getContentType()
            print(chan)" and Size:"
            print(chan)uploadFile!.getContentLength()
            print(chan)"bytes.<br>"
        else
            print(chan)"Please upload a file<br>"
            print(chan)"<form id='upload' method='post' action='upload' enctype='multipart/form-data' >"
            print(chan)"<input id='thefile' name='thefile' type='file' /><br>"
            print(chan)"<input type='submit' value='submit' id='submit' />"
            print(chan)"</form>"
        endif
        print(chan)”</body></html>”
        close(chan)
    methodend
classend

See Also

BBjAPI

BBjServletEvent

BBjHttpRequest

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.