Mohammad Robih T. Z
Mohammad Robih T. Z

Reputation: 11

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

Upvotes: 1

Views: 1349

Answers (2)

Alemoh Rapheal Baja
Alemoh Rapheal Baja

Reputation: 762

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",

Upvotes: 1

Shirly Manor
Shirly Manor

Reputation: 301

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"))

Upvotes: 3

Related Questions