gpt4 book ai didi

php - 无法在 laravel 5.2 中使用 Storage::put($file, $content) 保存我的文件

转载 作者:行者123 更新时间:2023-12-01 11:24:53 25 4
gpt4 key购买 nike

只是一个简单的疑问-

我正在尝试使用存储门面将我的图像和视频文件存储在存储中。
但我很困惑,因为我无法将该文件存储在存储文件夹中。
我正在使用干预图像包,当我尝试保存修改后的 $file 时
Storage::put($file);它抛出错误,缺少 2 个参数等。

我在网上到处搜索这个问题,我发现
Storage::put($file , $content)现在,当我尝试将图像保存到我的文件夹时,在这种情况下 $content 是什么?请给我例子-

还有一件事情

我如何返回可以从不同域访问的该文件的完整路径。
我正在构建一个 API :)

我在这里先向您的帮助表示感谢

最佳答案

您使用什么磁盘“公共(public)”,“本地”基本上是您存储它的地方?

   \Storage::disk('local')->put($file_name, $the_file);

磁盘设置可以在 config/filesystems.php查看文件。

还有 $content是您要保存的实际项目/文件。这是我最近做的一个例子..
   // the $image is from $request->file('file');
$thefile = \File::get($image);
$file_name = $title->slug . '-' . $year . '.jpg';
\Storage::disk('local')->put($file_name, $thefile);

关于php - 无法在 laravel 5.2 中使用 Storage::put($file, $content) 保存我的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38233688/

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