Php 如何在laravel存储目录中保存图像
我需要将使用base64转换的图像保存到存储目录,而不是保存在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
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目录