简体   繁体   中英

How to upload images on selected folder in Cloudinary using PHP Laravel framework?

I created Cloudinary account and made a "posts" folder.

I want to store all images upload on posts folder but I don't know how to do that.

I'm using this package https://github.com/jrm2k6/cloudder

Here is a sample code:

\Cloudinary\Uploader::upload("myImage.jpg", 
  array("folder" => "my_folder/my_sub_folder/", "public_id" => "my_image", "overwrite" => TRUE, 
"resource_type" => "image"))

So let's say the name of the folder is posts

$image_path = $request->file('image_name')->getRealPath();

Cloudder::upload($image_path, null, array("folder" => "posts", "overwrite" => TRUE, "resource_type" => "image"));

the null parameter allows cloudinary to generate a unique public id for the uploaded image.

public_id: "posts/unique_id.png",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM