How to give permission to public folder to store image.

Posted 2 months ago by Jaikangam

Hi Developer,

Hope you are doing good. I am finding hard time to solve this. Please help me

I am form which accept image to insert into Database.

Controller to store image

...
if($request->hasFile('webinarphoto')){
     $file1 = $request->webinarphoto; //Image from the browser 
     $filename = time().'.'. $file1->getClientOriginalExtension(); //getting the extension an filename to save 
     $location = public_path('images/webinar/' .$filename); //setting the file location 

      Image::make($file1)->resize(500,500)->save($location); //Resize the file into 500x500 and save it into public folder 'images/webinar/filename.jpg' 
           
     $inserts ->webinarphoto = $filename; //finally insert the filename into database. 
 }
...

This work fine on the local development

But when i run on production it is giving me error

(1/1) NotWritableException
Can't write image data to path (/var/www/foldername/public/images/webinar/1557987359.jpg)

How do i solve this

Please sign in or create an account to participate in this conversation.