From a9069cf39d1899824c5e2dd616ea0f5581fee037 Mon Sep 17 00:00:00 2001 From: hexl Date: Sat, 9 May 2015 23:52:39 +0800 Subject: [PATCH 1/3] Update FileController.php add a char to the file name to fix chinese. --- controllers/FileController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/FileController.php b/controllers/FileController.php index 37e7803..6322e35 100644 --- a/controllers/FileController.php +++ b/controllers/FileController.php @@ -27,7 +27,7 @@ public function actionUpload() $result['uploadedFiles'] = []; if (is_array($model->file)) { foreach ($model->file as $file) { - $path = $this->getModule()->getUserDirPath() . DIRECTORY_SEPARATOR . $file->name; + $path = $this->getModule()->getUserDirPath() . DIRECTORY_SEPARATOR . '_' . $file->name; // add a '_' to fix chinese file name; hexl 2015-05-09 $file->saveAs($path); $result['uploadedFiles'][] = $file->name; } From 70d3f0eac518b12bb27b7538fd3a0b8861d1cd05 Mon Sep 17 00:00:00 2001 From: hexl Date: Sun, 10 May 2015 11:14:50 +0800 Subject: [PATCH 2/3] Update FileController.php recommit --- controllers/FileController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/FileController.php b/controllers/FileController.php index 6322e35..ce2815b 100644 --- a/controllers/FileController.php +++ b/controllers/FileController.php @@ -27,7 +27,7 @@ public function actionUpload() $result['uploadedFiles'] = []; if (is_array($model->file)) { foreach ($model->file as $file) { - $path = $this->getModule()->getUserDirPath() . DIRECTORY_SEPARATOR . '_' . $file->name; // add a '_' to fix chinese file name; hexl 2015-05-09 + $path = $this->getModule()->getUserDirPath() . DIRECTORY_SEPARATOR . '_' . $file->name; // add a '_' to fix chinese file name; hexl 2015-05-10 $file->saveAs($path); $result['uploadedFiles'][] = $file->name; } From 932f49f9738e18abf622f53839d525ee4a5c4747 Mon Sep 17 00:00:00 2001 From: hexl Date: Sun, 10 May 2015 11:20:07 +0800 Subject: [PATCH 3/3] Update Module.php remove the first '_' added when save to temp folder; hexl 2015-05-09 --- Module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Module.php b/Module.php index c0ebceb..1d828b5 100644 --- a/Module.php +++ b/Module.php @@ -137,7 +137,7 @@ public function attachFile($filePath, $owner) $file = new File(); - $file->name = pathinfo($filePath, PATHINFO_FILENAME); + $file->name = substr(pathinfo($filePath, PATHINFO_FILENAME), 1); // remove the first '_' added when save to temp folder; hexl 2015-05-10 $file->model = $this->getShortClass($owner); $file->itemId = $owner->id; $file->hash = $fileHash;