Browse Source

文件上传错误信息返回

jqh 4 năm trước cách đây
mục cha
commit
2df048e49d
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      src/Form/Field/UploadField.php

+ 3 - 2
src/Form/Field/UploadField.php

@@ -343,8 +343,9 @@ trait UploadField
     {
         $rules = $attributes = [];
 
-        if ($errors = $file->getErrorMessage()) {
-            return $errors;
+        // 如果文件上传有错误,则直接返回错误信息
+        if ($file->getError() !== UPLOAD_ERR_OK) {
+            return $file->getErrorMessage();
         }
 
         if (! $fieldRules = $this->getRules()) {