Browse Source

UplodedFile enhasement

tags/2.0.0-beta
andrey 11 years ago
parent
commit
264e61101a
  1. 26
      framework/yii/web/UploadedFile.php

26
framework/yii/web/UploadedFile.php

@ -33,20 +33,12 @@ class UploadedFile extends Object
*/
public $name;
/**
* @var string the original base file name
*/
public $baseName;
/**
* @var 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 $tempName;
/**
* @var string file extension.
*/
public $extension;
/**
* @var 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 [[FileHelper::getMimeType()]] to determine the exact MIME type.
@ -171,6 +163,22 @@ class UploadedFile extends Object
}
return false;
}
/**
* @return string original file base name
*/
public function getBaseName()
{
return pathinfo($this->name, PATHINFO_FILENAME);
}
/**
* @return string file extension
*/
public function getExtension()
{
return strtolower(pathinfo($this->name, PATHINFO_EXTENSION));
}
/**
* @return boolean whether there is an error with the uploaded file.
@ -216,9 +224,7 @@ class UploadedFile extends Object
} else {
self::$_files[$key] = new static([
'name' => $names,
'baseName' => pathinfo($names, PATHINFO_FILENAME),
'tempName' => $tempNames,
'extension' => strtolower(pathinfo($names, PATHINFO_EXTENSION)),
'type' => $types,
'size' => $sizes,
'error' => $errors,

Loading…
Cancel
Save