将图像上传到 Cloudinary - Laravel

Uploading images to Cloudinary - Laravel

在 CloudinaryController 中,我从 $request 获取本地文件(图像)并将其上传到 Cloudinary

public static function uploadImage($path, $image_name, $id)
    {
       Cloudder::upload($path, $image_name);
       $image_url= Cloudder::show(Cloudder::getPublicId());
       $this->saveImage($image_url, $id); // saving url to DB
       return redirect()->back()->with('status', 'Image Uploaded Successfully');
    }

如何将带有上述代码的图像上传到目录 home/users 而不是主页?

Cloudianry 在 uploading 时支持 folder 参数。

因此您可以将 folder 参数设置为 home/users 以将图像上传到该文件夹​​。

虽然我们不正式支持 cloudder wrapper,但您似乎可以将 folder 参数添加到 cloudder

中的 $options

即将 Cloudder::upload($path, $image_name); 更改为 Cloudder::upload($path, $options, $image_name);

添加了参数 $folder 并且效果很好,感谢您的帮助!

Cloudder::upload($path, $image_name, ['folder' => $folder]);