From 29693f68fdf65ef1d5edc3f70bf63ceb6473970f Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 8 Jan 2014 19:55:16 +0200 Subject: [PATCH 1/4] UplodedFile enhasement --- framework/yii/web/UploadedFile.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/framework/yii/web/UploadedFile.php b/framework/yii/web/UploadedFile.php index 1de4d46..c02df23 100644 --- a/framework/yii/web/UploadedFile.php +++ b/framework/yii/web/UploadedFile.php @@ -33,12 +33,20 @@ 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. @@ -208,7 +216,9 @@ 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, From 264e61101a7c188a1276fe492d66ea32f8f1e83e Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 8 Jan 2014 20:10:32 +0200 Subject: [PATCH 2/4] UplodedFile enhasement --- framework/yii/web/UploadedFile.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/framework/yii/web/UploadedFile.php b/framework/yii/web/UploadedFile.php index c02df23..5e1e428 100644 --- a/framework/yii/web/UploadedFile.php +++ b/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, From 006a139ed3a8e8844d408773cb035b70c56f1a31 Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 8 Jan 2014 20:41:16 +0200 Subject: [PATCH 3/4] UplodedFile enhasement --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 6c66691..598acf3 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -75,6 +75,7 @@ Yii Framework 2 Change Log - New #66: [Auth client library](https://github.com/yiisoft/yii2-authclient) OpenId, OAuth1, OAuth2 clients (klimov-paul) - New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo) - New #1438: [MongoDB integration](https://github.com/yiisoft/yii2-mongodb) ActiveRecord and Query (klimov-paul) +- Enh #1839: Added support for getting file extension and basename from uploaded file 2.0.0 alpha, December 1, 2013 --------------------------- From 2619fb096d8506365a81175e49b3b1a9f9f6f053 Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 8 Jan 2014 20:42:09 +0200 Subject: [PATCH 4/4] UplodedFile enhasement --- framework/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 598acf3..22ec170 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -75,7 +75,7 @@ Yii Framework 2 Change Log - New #66: [Auth client library](https://github.com/yiisoft/yii2-authclient) OpenId, OAuth1, OAuth2 clients (klimov-paul) - New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo) - New #1438: [MongoDB integration](https://github.com/yiisoft/yii2-mongodb) ActiveRecord and Query (klimov-paul) -- Enh #1839: Added support for getting file extension and basename from uploaded file +- Enh #1839: Added support for getting file extension and basename from uploaded file (anfrantic) 2.0.0 alpha, December 1, 2013 ---------------------------