Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在laravel存储目录中保存图像_Php_Laravel_Base64_Laravel 7_Intervention - Fatal编程技术网

Php 如何在laravel存储目录中保存图像

Php 如何在laravel存储目录中保存图像,php,laravel,base64,laravel-7,intervention,Php,Laravel,Base64,Laravel 7,Intervention,我需要将使用base64转换的图像保存到存储目录,而不是保存在public文件夹中 这是我的存储功能,它将图像保存到我的public目录中 public function store(Request $request, Category $category) { if ($request->image) { $name = time().'.'. explode('/', explode(':',substr($request->image, 0, strpo

我需要将使用base64转换的图像保存到存储目录,而不是保存在
public
文件夹中

这是我的存储功能,它将图像保存到我的
public
目录中

public function store(Request $request, Category $category)
{
    if ($request->image) {
        $name = time().'.'. explode('/', explode(':',substr($request->image, 0, strpos($request->image, ';')))[1])[1];

        Image::make($request->image)->save(public_path('img/category/').$name);

    return response('success');
}
我需要知道如何将图像保存到我的存储文件夹中,

如中所述,在我的本地laravel安装中,我导入了以下内容:

use Illuminate\Support\Facades\Storage;
然后在存储方法中:

Storage::disk('local')->put(time() . '.' . 'example.txt', 'Contents');

它将文件存储到storage/app而不是public目录。

您是否运行了php artisan storage:link?@tariquimtinan是的,我需要知道如何编写函数将数据保存到存储目录,上面的代码将文件保存到public/img/category目录