gpt4 book ai didi

php - 拉维尔 5 |图片上传 |无法获取上传变量的数据

转载 作者:行者123 更新时间:2023-12-03 23:02:35 24 4
gpt4 key购买 nike

我用,

$up = request::file('image')->move('../public/images');

将图片上传到“Public/images”目录。

我尝试使用“dd()”来了解“$up”的数据。

我得到的数据是,

 UploadedFile {#183 ▼
-test: false
-originalName: "Brackpoints.png"
-mimeType: "image/png"
-size: 148276
-error: 0
path: "/tmp"
filename: "phpmU8PvU"
basename: "phpmU8PvU"
pathname: "/tmp/phpmU8PvU"
extension: ""
realPath: "/tmp/phpmU8PvU"
aTime: 2016-02-15 13:57:39
mTime: 2016-02-15 13:57:39
cTime: 2016-02-15 13:57:39
inode: 1443211
size: 148276
perms: 0100600
owner: 900
group: 900
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}

如果我尝试“print_r()”,那么我得到,

 Illuminate\Http\UploadedFile Object
(
[test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
[originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => Brackpoints.png
[mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => image/png
[size:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 148276
[error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
[pathName:SplFileInfo:private] => /tmp/phpMhUyh0
[fileName:SplFileInfo:private] => phpMhUyh0
)

Symfony\Component\HttpFoundation\File\File Object
(
[pathName:SplFileInfo:private] => ../public/images/phpMhUyh0
[fileName:SplFileInfo:private] => phpMhUyh0
)

在这里,我想获取图像的名称和类型...

我怎样才能得到?

最佳答案

$up->getClientOriginalName();

$up->getMimeType();

关于php - 拉维尔 5 |图片上传 |无法获取上传变量的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35411444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com