英文:
How to save image intervention stream image in public folder laravel
问题
我正在将图像文件保存在存储文件夹中,它运行正常
$ext = "jpg";
$imageConvert = \Image::make($image->getRealPath())->stream($ext, 60);
$img = rand(10, 100) . '_piku.' . $ext;
\Storage::put('public/piku/' . $img, $imageConvert);
但我想将图像存储在直接的 public/piku 文件夹中,而不是 storage/app/public/piku
那我应该如何做呢?
我尝试了所有这些:[点击这里](https://stackoverflow.com/questions/62377351/laravel-image-intervention-resize-and-put-in-storage)
但这些方法对于 intervention stream 的情况不起作用。
英文:
I'm saving image file in storage folder, its working fine
$ext = "jpg";
$imageConvert = \Image::make($image->getRealPath())->stream($ext, 60);
$img = rand(10, 100) . '_piku.' . $ext;
\Storage::put('public/piku/' . $img, $imageConvert);
But I want to store images in direct public/piku folder instead of storage/app/public/piku
So how can I do that?
I have tried all these: click here
But these methods not work for case of intervention stream.
答案1
得分: 1
尝试使用public_path函数:
public_path
函数返回您的应用程序公共目录的完全限定路径。
$imageConvert->save(public_path('piku/' . $img));
英文:
try using public_path function:
The public_path
function returns the fully qualified path to your application's public directory.
$imageConvert->save(public_path('piku/' . $img));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论