jqh 5 years ago
parent
commit
ace8fb400d
1 changed files with 14 additions and 1 deletions
  1. 14 1
      src/Form/Field/UploadField.php

+ 14 - 1
src/Form/Field/UploadField.php

@@ -70,6 +70,11 @@ trait UploadField
      */
     protected $retainable = false;
 
+    /**
+     * @var bool
+     */
+    protected $saveFullUrl = false;
+
     /**
      * Initialize the storage instance.
      *
@@ -160,6 +165,13 @@ trait UploadField
         return $this;
     }
 
+    public function saveFullUrl(bool $value = true)
+    {
+        $this->saveFullUrl = $value;
+
+        return $this;
+    }
+
     /**
      * Upload File.
      *
@@ -195,9 +207,10 @@ trait UploadField
 
         if ($result) {
             $path = $this->getUploadPath();
+            $url = $this->objectUrl($path);
 
             // 上传成功
-            return $this->responseUploaded($path, $this->objectUrl($path));
+            return $this->responseUploaded($this->saveFullUrl ? $url : $path, $url);
         }
 
         // 上传失败