[英]Accessing file properties from a Request in Laravel
Below given is the request array while submitting a form with a file and some texts.下面给出的是提交带有文件和一些文本的表单时的请求数组。
array:6 [▼
"_token" => "jcM4LprgOI9Vx9JzcFUE0rUMXxRVHGe8XgOm4CcH"
"name" => "Some1"
"email" => "some@gmail.com"
"description" => "Just description."
"birth_year" => "1287"
"file_upload" => Illuminate\Http\UploadedFile {#1214 ▼
-test: false
-originalName: "Skin Infections.pdf"
-mimeType: "application/pdf"
-error: 0
#hashName: null
path: "C:\xampp_php8\tmp"
filename: "phpDC93.tmp"
basename: "phpDC93.tmp"
pathname: "C:\xampp_php8\tmp\phpDC93.tmp"
extension: "tmp"
realPath: "C:\xampp_php8\tmp\phpDC93.tmp"
aTime: 2021-11-02 21:59:01
mTime: 2021-11-02 21:59:00
cTime: 2021-11-02 21:59:00
inode: 15199648742567782
size: 53388
perms: 0100666
owner: 0
group: 0
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
linkTarget: "C:\xampp_php8\tmp\phpDC93.tmp"
}
]
For getting the common File methods I can always refer to the UploadFile class from Symfony.为了获得常用的 File 方法,我总是可以参考 Symfony 的 UploadFile 类。 link: https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/HttpFoundation/File/UploadedFile.php
链接: https : //github.com/symfony/symfony/blob/5.4/src/Symfony/Component/HttpFoundation/File/UploadedFile.php
But how do I directly access the -originalName or size or executable property of the file_upload key?但是如何直接访问 file_upload 键的 -originalName 或 size 或 executable 属性?
For Accessing it directly you can use Laravel files要直接访问它,您可以使用 Laravel 文件
Ex:-前任:-
$image = $request->file('file_upload'); $image = $request->file('file_upload');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.