Laravel不存储来自请求的文件 [英] Laravel not storing files from request

查看:103
本文介绍了Laravel不存储来自请求的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了带有名为"image"的文件上传的表格.表格正在运行,我正在获取图像,但由于某种原因它没有被存储.这是我用来存储图像的代码:

I got form with file upload named "image". Form is working and i'm getting image but for some reason it's not stored. this is the code I use to store image:

$path = $request->image->store('storage/uploads');

在我检查之前

$request->hasFile('image')

,然后我保存$ path.路径已成功保存,当我检查它时,它确实是存储/上传/radnomid文件,但没有文件

and later I'm saving $path. Path is successfully saved and when i check it it's really storage/uploads/radnomid but there is no file

推荐答案

很抱歉发布我自己的答案,但问题是默认情况下laravel公共磁盘不会上传到公共目录.设置需要像这样更改: config/filesystems.php

Sorry for posting my own answer but problem was that by default laravel public disk does not upload to public directory. Settings needed to be changed like this: config/filesystems.php

  'public' => [
              'driver'     => 'local',
              'root'       => public_path(),
              'visibility' => 'public',
          ],

然后简单地:

$path = $request->image->store('storage/uploads','public');

这篇关于Laravel不存储来自请求的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆