Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • ActionFormModelBase
  • CActiveDataProvider
  • CalendarEventFormModel
  • CallFormModel
  • CArrayDataProvider
  • CAssetManager
  • CBaseController
  • CBaseUrlRule
  • CCacheHttpSession
  • CClientScript
  • CController
  • CCookieCollection
  • CDataProvider
  • CDataProviderIterator
  • CDbHttpSession
  • CExtController
  • CFormModel
  • CHttpCookie
  • CHttpRequest
  • CHttpSession
  • CHttpSessionIterator
  • COutputEvent
  • CPagination
  • CreatePageFormModel
  • CSort
  • CSqlDataProvider
  • CTheme
  • CThemeManager
  • CUploadedFile
  • CUrlManager
  • CUrlRule
  • CWebApplication
  • CWebModule
  • CWidgetFactory
  • EditMobileFormsFormModel
  • EventCommentPublisherFormModel
  • EventFormModel
  • EventPublisherFormModel
  • FileSystemObjectDataProvider
  • MassActionFormModel
  • MobilePagination
  • NoteFormModel
  • NotificationsController
  • TimeFormModel
  • UploadLogoFormModel
  • X2FormModel
  • X2HttpRequest

Interfaces

  • IDataProvider
  • IWidgetFactory
  • Overview
  • Package
  • Class
  • Tree

Class CUploadedFile

CUploadedFile represents the information for an uploaded file.

Call CUploadedFile::getInstance() to retrieve the instance of an uploaded file, and then use CUploadedFile::saveAs() to save it on the server. You may also query other information about the file, including name, tempName, type, size and error.

CComponent
Extended by CUploadedFile
Package: system\web
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/web/CUploadedFile.php
Methods summary
public static CUploadedFile
# getInstance( CModel $model, string $attribute )

Returns an instance of the specified uploaded file. The file should be uploaded using CHtml::activeFileField().

Returns an instance of the specified uploaded file. The file should be uploaded using CHtml::activeFileField().

Parameters

$model
CModel
$model the model instance
$attribute
string
$attribute the attribute name. For tabular file uploading, this can be in the format of "[$i]attributeName", where $i stands for an integer index.

Returns

CUploadedFile
the instance of the uploaded file. Null is returned if no file is uploaded for the specified model attribute.

See

CUploadedFile::getInstanceByName()
public static CUploadedFile[]
# getInstances( CModel $model, string $attribute )

Returns all uploaded files for the given model attribute.

Returns all uploaded files for the given model attribute.

Parameters

$model
CModel
$model the model instance
$attribute
string
$attribute the attribute name. For tabular file uploading, this can be in the format of "[$i]attributeName", where $i stands for an integer index.

Returns

CUploadedFile[]
array of CUploadedFile objects. Empty array is returned if no available file was found for the given attribute.
public static CUploadedFile
# getInstanceByName( string $name )

Returns an instance of the specified uploaded file. The name can be a plain string or a string like an array element (e.g. 'Post[imageFile]', or 'Post[0][imageFile]').

Returns an instance of the specified uploaded file. The name can be a plain string or a string like an array element (e.g. 'Post[imageFile]', or 'Post[0][imageFile]').

Parameters

$name
string
$name the name of the file input field.

Returns

CUploadedFile
the instance of the uploaded file. Null is returned if no file is uploaded for the specified name.
public static CUploadedFile[]
# getInstancesByName( string $name )

Returns an array of instances starting with specified array name.

Returns an array of instances starting with specified array name.

If multiple files were uploaded and saved as 'Files[0]', 'Files[1]', 'Files[n]'..., you can have them all by passing 'Files' as array name.

Parameters

$name
string
$name the name of the array of files

Returns

CUploadedFile[]
the array of CUploadedFile objects. Empty array is returned if no adequate upload was found. Please note that this array will contain all files from all subarrays regardless how deeply nested they are.
public static
# reset( )

Cleans up the loaded CUploadedFile instances. This method is mainly used by test scripts to set up a fixture.

Cleans up the loaded CUploadedFile instances. This method is mainly used by test scripts to set up a fixture.

Since

1.1.4
protected static
# prefetchFiles( )

Initially processes $_FILES superglobal for easier use. Only for internal usage.

Initially processes $_FILES superglobal for easier use. Only for internal usage.

protected static
# collectFilesRecursive( string $key, mixed $names, mixed $tmp_names, mixed $types, mixed $sizes, mixed $errors )

Processes incoming files for CUploadedFile::getInstanceByName().

Processes incoming files for CUploadedFile::getInstanceByName().

Parameters

$key
string
$key key for identifiing uploaded file: class name and subarray indexes
$names
mixed
$names file names provided by PHP
$tmp_names
mixed
$tmp_names temporary file names provided by PHP
$types
mixed
$types filetypes provided by PHP
$sizes
mixed
$sizes file sizes provided by PHP
$errors
mixed
$errors uploading issues provided by PHP
public
# __construct( string $name, string $tempName, string $type, integer $size, integer $error )

Constructor. Use CUploadedFile::getInstance() to get an instance of an uploaded file.

Constructor. Use CUploadedFile::getInstance() to get an instance of an uploaded file.

Parameters

$name
string
$name the original name of the file being uploaded
$tempName
string
$tempName the path of the uploaded file on the server.
$type
string
$type the MIME-type of the uploaded file (such as "image/gif").
$size
integer
$size the actual size of the uploaded file in bytes
$error
integer
$error the error code
public string
# __toString( )

String output. This is PHP magic method that returns string representation of an object. The implementation here returns the uploaded file's name.

String output. This is PHP magic method that returns string representation of an object. The implementation here returns the uploaded file's name.

Returns

string
the string representation of the object
public boolean
# saveAs( string $file, boolean $deleteTempFile = true )

Saves the uploaded file. Note: this method uses php's move_uploaded_file() method. As such, if the target file ($file) already exists it is overwritten.

Saves the uploaded file. Note: this method uses php's move_uploaded_file() method. As such, if the target file ($file) already exists it is overwritten.

Parameters

$file
string
$file the file path used to save the uploaded file
$deleteTempFile
boolean
$deleteTempFile whether to delete the temporary file after saving. If true, you will not be able to save the uploaded file again in the current request.

Returns

boolean
true whether the file is saved successfully
public string
# getName( )

Returns

string
the original name of the file being uploaded
public string
# getTempName( )

Returns

string
the path of the uploaded file on the server. Note, this is a temporary file which will be automatically deleted by PHP after the current request is processed.
public string
# getType( )

Returns

string
the MIME-type of the uploaded file (such as "image/gif"). Since this MIME type is not checked on the server side, do not take this value for granted. Instead, use CFileHelper::getMimeType() to determine the exact MIME type.
public integer
# getSize( )

Returns

integer
the actual size of the uploaded file in bytes
public integer
# getError( )

Returns an error code describing the status of this file uploading.

Returns an error code describing the status of this file uploading.

Returns

integer
the error code

See

http://www.php.net/manual/en/features.file-upload.errors.php
public boolean
# getHasError( )

Returns

boolean
whether there is an error with the uploaded file. Check error for detailed error code information.
public string
# getExtensionName( )

Returns

string
the file extension name for name. The extension name does not include the dot character. An empty string is returned if name does not have an extension name.
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Magic properties summary
public string $name
#

The original name of the file being uploaded.

The original name of the file being uploaded.

public string $tempName
#

The path of the uploaded file on the server. Note, this is a temporary file which will be automatically deleted by PHP after the current request is processed.

The path of the uploaded file on the server. Note, this is a temporary file which will be automatically deleted by PHP after the current request is processed.

public string $type
#

The MIME-type of the uploaded file (such as "image/gif"). Since this MIME type is not checked on the server side, do not take this value for granted. Instead, use CFileHelper::getMimeType() to determine the exact MIME type.

The MIME-type of the uploaded file (such as "image/gif"). Since this MIME type is not checked on the server side, do not take this value for granted. Instead, use CFileHelper::getMimeType() to determine the exact MIME type.

public integer $size
#

The actual size of the uploaded file in bytes.

The actual size of the uploaded file in bytes.

public integer $error
#

The error code.

The error code.

public boolean $hasError
#

Whether there is an error with the uploaded file. Check error for detailed error code information.

Whether there is an error with the uploaded file. Check error for detailed error code information.

public string $extensionName
#

The file extension name for name. The extension name does not include the dot character. An empty string is returned if name does not have an extension name.

The file extension name for name. The extension name does not include the dot character. An empty string is returned if name does not have an extension name.

API documentation generated by ApiGen 2.8.0