فهرست منبع

Fixed:上传文件名保持问题

Zhu Jinhui 7 سال پیش
والد
کامیت
d3a9e0f2a6
1فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 4 4
      src/Library/Upload.php

+ 4 - 4
src/Library/Upload.php

@@ -387,7 +387,7 @@ class Upload
         
         $extension = '.' . $extension;
         //如果是设置了保持文件名称的话,就不自动转换文件名
-        if (isset($configure['keepFileName'])) {
+        if (isset($configure['keepFileName']) && $configure['keepFileName']) {
             $fileName = pathinfo($files['name'], PATHINFO_FILENAME);
         } else {
             $fileName = rand(10000, 90000) . uniqid();
@@ -409,11 +409,11 @@ class Upload
             }
         }
         //将文件名转换成URL编码,防止移动文件不成功的情况
-        $realPath = rtrim($fillPath, '/') . '/' . urlencode($configure['fileName']);
+        $realPath = rtrim($fillPath, '/') . '/' . $configure['fileName'];
         if ($files['binary']) {
-            $result = rename($files['tmp_name'], $realPath);
+            $result = @rename($files['tmp_name'], $realPath);
         } else {
-            $result = move_uploaded_file($files['tmp_name'], $realPath);
+            $result = @move_uploaded_file($files['tmp_name'], $realPath);
         }
         if ($result) {
             $data['code'] = 0;