Reputation: 981
I have a problem with permissions. On my host i created a folder images on /home/public_html/images and set the full permission from cpanel 777. When i try to upload an image using dropzone it says:
production.ERROR: exception 'Intervention\Image\Exception\NotWritableException' with message 'Can't write image data to path (/home/username/app_folder/public/images/15003681530.jpg)' in /home/username/app_folder/vendor/intervention/image/src/Intervention/Image/Image.php:143
Why is trying to write in /home/username/public/images folder? The folder is not in that path, is in /home/username/public_html/images
// create a unique name for each image
$filename = time() . $i . '.' . $image->getClientOriginalExtension();
// create a location
$location = public_path('images/').$filename;
// save the image to that location
Image::make($image->getRealPath())->resize(200,200)->save($location);
I am using laravel 5.4 and Intervention Image for laravel.
Upvotes: 0
Views: 379
Reputation: 981
I found this method:
$location = base_path().DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'public_html/images/'.$filename;
I`ll have to change this every time when i upload my project up. On localhost the public folder is in the project, when uploading the project on my domain i separate the public by the project. The content of the public folder is on the public_html folder and the project itself is on the root home folder
Upvotes: 0