Class FileUploadForm

Description

The FileUploadForm control class.

This control can be used to upload files to a folder on the server. Files are uploaded asynchronously, without reloading the page.

The control can be added to the page with the PHP and JavaScript add functions and can then be retrieved with Wigbi.getControl(id).

This control differs a bit from other controls, since it makes the form enable file handling. Thus, it is the only "official" control that uses the automated submit handling of the control base class. To make this work for AJAX added controls, the following must apply:

  • The page MUST have a dummy control with the same ID as the real control that is to be added with AJAX. Otherwise, the upload will be posted to a page without a control and fail.
  • The dummy control MUST be placed INSIDE the target container to which the AJAX-added upload form will be added. Otherwise, two controls with the same ID will exist on the page.

Note that the max file size is limited to the smallest value of the maxFileSize property or post_max_size in the php.ini file.

JAVASCRIPT ********************************

FileUploadForm : BaseControl

Properties:

  • public string fileTag()
  • public void setFileTag(string newVal)
  • public int maxFileSize()
  • public void setMaxFileSize(int newVal)
  • public int numUploads()
  • public void setNumUploads(int newVal)
  • public string uploadFolder()
  • public void setUploadFolder(string newVal)

Functions:

  • [ASYNC] public static void add(string controlId, string uploadFolder, string fileTag, int numUploads, int maxFileSize, string targetElementId, function onAdd())
  • [ASYNC] public void submit()

Events:

  • public bool onPreSubmit()
  • public void onSubmit(string[] uploadedFiles)
  • public void onSubmitError(string[] errorList)

Override onPreSubmit to set what to do before the form is being submitted. If it returns false, the submit operation will abort.

Override onSubmit to set what to do when the submit operation has finished. By default, it does nothing.

Override onSubmitError to set what to do when a submit operation fails. By default, it alerts all errors in the error list.

LANGUAGE HANDLING *************************

The following language parameters are used by the class:

  • [controlId] FileUploadForm fileNotSubmitted
  • [controlId] FileUploadForm filePartiallyUploaded
  • [controlId] FileUploadForm fileTooLarge_php
  • [controlId] FileUploadForm fileTooLarge_form
  • [controlId] FileUploadForm noFile
  • [controlId] FileUploadForm noWriteAccess
  • [controlId] FileUploadForm reset
  • [controlId] FileUploadForm submit
  • [controlId] FileUploadForm submitError
  • [controlId] FileUploadForm submitErrorMessage
  • [controlId] FileUploadForm submitted
  • [controlId] FileUploadForm submitting
  • [controlId] FileUploadForm tempFolderMissing
  • [controlId] FileUploadForm uploadFolderInvalid
  • [controlId] FileUploadForm uploadFolderRequired
  • [controlId] FileUploadForm uploadStopped

Located in /wigbi_controls/FileUploadForm.php (line 125)

BaseControl
   |
   --FileUploadForm
Method Summary
 static void add (string $controlId, string $uploadFolder, [string $fileTag = ""], [int $numUploads = 1], [int $maxFileSize = 100000000])
 static array upload (mixed $files, string $uploadFolder, [string $fileTag = ""], string $controlId)
 FileUploadForm __construct ( $controlId)
 void submit ()
Methods
static add (line 346)

Add a FileUploadForm control to the page.

  • access: public
static void add (string $controlId, string $uploadFolder, [string $fileTag = ""], [int $numUploads = 1], [int $maxFileSize = 100000000])
  • string $controlId: The unique control ID.
  • string $uploadFolder: The application relative upload folder.
  • string $fileTag: The tag to add to each uploaded file; default blank.
  • int $numUploads: The number of file uploads to support; default 1.
  • int $maxFileSize: The maximum supported file upload size; default 100000000 bytes.
static upload (line 411)

Upload files to the server.

  • return: A list of error codes; empty if no error occured.
  • access: public
static array upload (mixed $files, string $uploadFolder, [string $fileTag = ""], string $controlId)
  • string $controlId: The ID of the submitting control, is any; set to blank if none.
  • mixed $files: The uploaded files; has to be passed as the $_FILE object.
  • string $uploadFolder: The application relative upload folder.
  • string $fileTag: The tag to add to each uploaded file; default blank.
Constructor __construct (line 136)

Create an instance of the control.

This constructor is only to be used by Wigbi at startup.

  • access: public
FileUploadForm __construct ( $controlId)
  • $controlId

Redefinition of:
BaseControl::__construct()
Create an instance of the class.
submit (line 388)

The main submit function.

  • access: protected
void submit ()

Redefinition of:
BaseControl::submit()
Submit the control and handle any data that has been posted by it.

Inherited Methods

Inherited From BaseControl

 BaseControl::__construct()
 BaseControl::closeForm()
 BaseControl::controlId()
 BaseControl::isPostBackSource()
 BaseControl::javaScript()
 BaseControl::openForm()
 BaseControl::registerJavaScript()
 BaseControl::submit()

Documentation generated on Sun, 27 Dec 2009 20:12:01 +0100 by phpDocumentor 1.4.1