I am using laravel 5.2 and faced a problem while working on image uploading. I am getting an error as
NotWritableException in Image.php line 143: Can't write image data to path (C:\Users\SurajLifeean\surj\public\images/)
This code is inside my controller.
$image=$request->file('featured_image');
$filename=time().'.'.$image->getClientOriginalExtension();
$location = public_path('images/',$filename);
Image::make($image)->resize(800,400)->save($location);$post->image=$filename;
i have accross a solution to include at the begining
use Illuminate\Support\Facades\File;
but it didnt help. can any one suggest me a solution
from your error message you got two issues,
1 ) NotWritableException
means that your folder you are trying to touch is not writeable, which means that you need to give that folder 777 permissions
2 ) you are under windows environment, while you are using UNIX directory separator.
it's always good practice to use the DIRECTORY_SEPARATOR
constant as directory separator instead of fixed separators.
as follows:
$location = public_path('images' . DIRECTORY_SEPARATOR, $filename);
or simply in your case use :
$location = public_path('images\', $filename);
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.