Navigation through a Laravel filebag

放肆的年华 提交于 2020-06-09 00:59:36

问题


I am using a medium editor image insert plugin, which has a dependency of bluimp image upload.

For the server side, I am trying to get the image before uploading it.

If if do:

dd($request->files)

I get this:

FileBag {#45
#parameters: array:1 [
"files" => array:1 [
  0 => UploadedFile {#30
    -test: false
    -originalName: "2015-07-17-018.jpg"
    -mimeType: "image/jpeg"
    -size: 240817
    -error: 0
    path: "/Applications/MAMP/tmp/php"
    filename: "phpiGBKNo"
    basename: "phpiGBKNo"
    pathname: "/Applications/MAMP/tmp/php/phpiGBKNo"
    extension: ""
    realPath: "/Applications/MAMP/tmp/php/phpiGBKNo"
    aTime: 2016-05-09 14:39:11
    mTime: 2016-05-09 14:39:11
    cTime: 2016-05-09 14:39:11
    inode: 37419151
    size: 240817
    perms: 0100600
    owner: 501
    group: 80
    type: "file"
    writable: true
    readable: true
    executable: false
    file: true
    dir: false
    link: false
  }
]
]
}

As you can see there is an image there, but I cannot seem to get the single image no matter what I do. Tried $request->files[0] / files->UploadedFile etc and nothing I have done will return that image.


回答1:


You can manipulate file with appropriate methods only:

$file = $request->file('photo');

$request->file('photo')->move($destinationPath, $fileName);

https://laravel.com/docs/5.1/requests#files

Also, you can use additional methods.



来源:https://stackoverflow.com/questions/37118682/navigation-through-a-laravel-filebag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!