我用,
$up = request::file('image')->move('../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
)
在这里,我想获得图片的名称和类型......
我怎么能得到?
答案 0 :(得分:3)
$up->getClientOriginalName();
$up->getMimeType();
答案 1 :(得分:1)
试试这个
echo $up->originalName;