Comments: on this page. Click to read or post your own.

Class Upload

Description

Manages uploads via HTML forms processed by PHP, uploads to Silverstripe's default upload directory, and either creates a new or uses an existing File-object for syncing with the database.

  • todo: Allow for non-database uploads

Located in /sapphire/filesystem/Upload.php (line 13)

Object
   |
   --ViewableData
      |
      --RequestHandlingData
         |
         --Controller
            |
            --Upload
Variable Summary
Method Summary
void clearErrors ()
int getAllowedMaxFileSize ([string $ext = null])
array getErrors ()
boolean isError ()
boolean isValidExtension (array $tmpFile)
boolean isValidSize (array $tmpFile)
Boolean|string load ($tmpFile $tmpFile, [$folderPath $folderPath = false])
Boolean loadIntoFile (array $tmpFile, File $file)
void setAllowedExtensions (array $rules)
void setAllowedMaxFileSize (array|int $rules)
void setFile (File $file)
boolean validate (array $tmpFile)
Variables
static string $uploads_folder = "Uploads" (line 66)

A foldername relative to /assets, where all uploaded files are stored by default.

  • access: public
array $allowedExtensions = array() (line 50)
  • var:

    Collection of extensions. Extension-names are treated case-insensitive.

    Example:

    1.      array("jpg","GIF")

  • access: public
array $allowedMaxFileSize = array() (line 37)

Restrict filesize for either all filetypes or a specific extension, with extension-name as array-key and the size-restriction in bytes as array-value.

  • access: public
array $errors = array() (line 58)

Processing errors that can be evaluated, e.g. by Form-validation.

  • access: protected
File $file (line 20)

A File object

  • access: protected
array $tmpFile (line 28)

Information about the temporary file produced by the PHP-runtime.

  • access: protected

Inherited Variables

Inherited from Controller

Controller::$action
Controller::$allowed_actions
Controller::$baseInitCalled
Controller::$basicAuthEnabled
Controller::$controller_stack
Controller::$request
Controller::$requestParams
Controller::$response
Controller::$session
Controller::$urlParams
Controller::$url_handlers

Inherited from ViewableData

ViewableData::$casting
ViewableData::$castingHelperPair_cache
ViewableData::$customisedObj
ViewableData::$failover
ViewableData::$iteratorPos
ViewableData::$iteratorTotalItems
ViewableData::$namedAs
ViewableData::$parent
ViewableData::$_natural_cache
ViewableData::$_object_cache
ViewableData::$_xml_cache

Inherited from Object

Object::$builtInMethods
Object::$class
Object::$classConstructed
Object::$extensions
Object::$extension_instances
Object::$extraMethods
Object::$extraStatics
Object::$statics
Object::$static_cached
Methods
clearErrors (line 304)

Clear out all errors (mostly set by {loadUploaded()})

  • access: public
void clearErrors ()
getAllowedExtensions (line 259)
  • access: public
array getAllowedExtensions ()
getAllowedMaxFileSize (line 225)

Get maximum file size for all or specified file extension.

  • return: Filesize in bytes
  • access: public
int getAllowedMaxFileSize ([string $ext = null])
  • string $ext
getErrors (line 323)

Return all errors that occurred while processing so far (mostly set by {loadUploaded()})

  • access: public
array getErrors ()
getFile (line 206)

Get file-object, either generated from {load()}, or manually set.

  • access: public
File getFile ()
isError (line 313)

Determines wether previous operations caused an error.

  • access: public
boolean isError ()
isValidExtension (line 295)

Determines if the temporary file has a valid extension

  • access: public
boolean isValidExtension (array $tmpFile)
  • array $tmpFile
isValidSize (line 283)

Determines if the bytesize of an uploaded file is valid - can be defined on an extension-by-extension basis in {$allowedMaxFileSize}

  • access: public
boolean isValidSize (array $tmpFile)
  • array $tmpFile
load (line 75)

Save an file passed from a form post into this object.

  • return: Either success or error-message.
Boolean|string load ($tmpFile $tmpFile, [$folderPath $folderPath = false])
  • $tmpFile $tmpFile: array Indexed array that PHP generated for every file it uploads.
  • $folderPath $folderPath: string Folder path relative to /assets
loadIntoFile (line 148)

Load temporary PHP-upload into File-object.

  • access: public
Boolean loadIntoFile (array $tmpFile, File $file)
  • array $tmpFile
  • File $file
setAllowedExtensions (line 266)
  • access: public
void setAllowedExtensions (array $rules)
  • array $rules
setAllowedMaxFileSize (line 246)

Set filesize maximums (in bytes).

Automatically converts extensions to lowercase for easier matching.

Example:

  1.  array('*' => 200'jpg' => 1000)

  • access: public
void setAllowedMaxFileSize (array|int $rules)
  • array|int $rules
setFile (line 215)

Set a file-object (similiar to {loadIntoFile()})

  • access: public
void setFile (File $file)
validate (line 164)

Container for all validation on the file (e.g. size and extension restrictions).

Is NOT connected to the {Validator} classes, please have a look at {FileField->validate()} for an example implementation of external validation.

  • access: public
boolean validate (array $tmpFile)
  • array $tmpFile

Inherited Methods

Inherited From Controller

Controller::AbsoluteLink()
Controller::can()
Controller::curr()
Controller::CurrentMember()
Controller::defaultAction()
Controller::disableBasicAuth()
Controller::getAction()
Controller::getFormOwner()
Controller::getRequest()
Controller::getResponse()
Controller::getSession()
Controller::getURLParams()
Controller::getViewer()
Controller::handleAction()
Controller::handleRequest()
Controller::has_curr()
Controller::init()
Controller::isAjax()
Controller::join_links()
Controller::Now()
Controller::PastMember()
Controller::PastVisitor()
Controller::popCurrent()
Controller::pushCurrent()
Controller::redirect()
Controller::redirectBack()
Controller::redirectedTo()
Controller::render()
Controller::setSession()
Controller::setURLParams()

Inherited From RequestHandlingData

RequestHandlingData::checkAccessAction()
RequestHandlingData::getRequest()
RequestHandlingData::handleRequest()
RequestHandlingData::httpError()

Inherited From ViewableData

ViewableData::ATT_val()
ViewableData::BaseHref()
ViewableData::buildCastingHelperCache()
ViewableData::cachedCall()
ViewableData::castingHelper()
ViewableData::castingHelperPair()
ViewableData::castingObjectCreator()
ViewableData::castingObjectCreatorPair()
ViewableData::CSSClasses()
ViewableData::CurrentMember()
ViewableData::CurrentPage()
ViewableData::customise()
ViewableData::Debug()
ViewableData::defineMethods()
ViewableData::escapeTypeForField()
ViewableData::Even()
ViewableData::EvenOdd()
ViewableData::First()
ViewableData::FirstLast()
ViewableData::getField()
ViewableData::getIterator()
ViewableData::getXMLValues()
ViewableData::hasField()
ViewableData::HasPerm()
ViewableData::hasValue()
ViewableData::i18nLocale()
ViewableData::IsAjax()
ViewableData::iteratorProperties()
ViewableData::JS_val()
ViewableData::Last()
ViewableData::Me()
ViewableData::Middle()
ViewableData::MiddleString()
ViewableData::obj()
ViewableData::Odd()
ViewableData::Pos()
ViewableData::RAW_val()
ViewableData::renderWith()
ViewableData::SecurityID()
ViewableData::setCustomisedObj()
ViewableData::setField()
ViewableData::SQL_val()
ViewableData::ThemeDir()
ViewableData::Top()
ViewableData::TotalItems()
ViewableData::val()
ViewableData::XML_val()
ViewableData::__get()
ViewableData::__isset()
ViewableData::__set()

Inherited From Object

Object::__construct()
Object::addMethodsFrom()
Object::addStaticVars()
Object::addWrapperMethod()
Object::add_extension()
Object::allMethodNames()
Object::buildMethodList()
Object::cacheToFile()
Object::cacheToFileWithArgs()
Object::create()
Object::createMethod()
Object::defineMethods()
Object::exists()
Object::extend()
Object::extInstance()
Object::getCustomClass()
Object::hasExtension()
Object::hasMethod()
Object::invokeWithExtensions()
Object::is_a()
Object::loadCache()
Object::parentClass()
Object::sanitiseCachename()
Object::saveCache()
Object::set_stat()
Object::set_uninherited()
Object::stat()
Object::strong_create()
Object::uninherited()
Object::useCustomClass()
Object::__call()
Object::__toString()
blog comments powered by Disqus

Documentation generated on Sun, 19 Oct 2008 06:47:25 +1300 by phpDocumentor 1.3.2