Agile Toolkit  4.2
Agile Toolkit is a powerful web development framework. Inspired by GUI Applications development
Form_Field_Upload Class Reference
Inheritance diagram for Form_Field_Upload:
Form_Field AbstractView AbstractObject

Public Member Functions

 allowMultiple ($multiple=50)
 setFormatFilesTemplate ($template)
 setMode ($mode)
 loadPOST ()
 uploadComplete ($data=null)
 uploadFailed ($message)
 init ()
 convertToBytes ($val)
 getUploadedFiles ()
 formatFiles ($data)
 getInput ()
 isUploaded ()
 getOriginalName ()
 getOriginalType ()
 getFilePath ()
 getFile ()
 getFileSize ()
 saveInto ($directory)
 displayUploadInfo ()
 debug ()

Data Fields

 $max_file_size = null
 $mode = 'iframe'
 $multiple = false
 $debug = false
 $format_files_template = "view/uploaded_files"

Detailed Description

This class is for uploading files. It supports 3 types of upload:

  • regular upload. No javascript is involved. When form is being submitted, data is collected
  • javascript iframe upload. Upon selection of the file, it will start uploading it right away, and will display additional file upload field, so that you can pick another file.
  • flash upload. Upload will be carried through by flash.

Mode can be set by setMode('plain') - plain mode is not available with AJAX form setMode('iframe') setMode('flash')

by Default mode is iframe.

allowMultiple(boolean=true) this function will allow you to specify whether you want user to upload multiple files.

by default, single mode is used

Mode Support. You can use setModel('filestore/File'); This will use the model for file upload handling. You can specify your own model, which derives from either filestore or filestore Field value will always contain "id" of uploaded file. If multiple file upload is permitted, field will contain comma-separated list of IDs.

Example1: Simple use with model

$upl=$form->addField('upload','myfile_id') ->setModel('filestore/File');

Example2: Customizing field

$upl=$form->addField('upload','photo_id','Photo') ->setController('filestore/Image') ->allowMultiple(false) ; $upl->template->set('after_field','Max size: 500k');

Example3: Specifying inside Model

$model=$this->add('Model_Book'); $model->add('filestore/Field_Image','picture_id');


Example4: Use of your custom model

$this->api->stickyGET('user_id'); $myfile=$this->add('filestore/Image'); $myfile->join('user_images.file_id')->setMasterField('user_id',$_GET['user_id']); $form->addField('upload','photo') ->setNoSave()->setModel($myfile);

This last example will implement many-to-many relationship between file object and user_id. This is implemented through intermediate table user_images, which is joined with an image model.

Member Function Documentation

allowMultiple ( multiple = 50)
convertToBytes ( val)
debug ( )
formatFiles ( data)
getFile ( )
getInput ( )
init ( )

Initialize object. Always call parent

This method is called for initialization

Reimplemented from Form_Field.

loadPOST ( )

Reimplemented from Form_Field.

saveInto ( directory)
setFormatFilesTemplate ( template)
setMode ( mode)
uploadComplete ( data = null)
uploadFailed ( message)

Field Documentation

$debug = false
$format_files_template = "view/uploaded_files"
$max_file_size = null
$mode = 'iframe'
$multiple = false

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Enumerations