Tuesday, February 28, 2017

Unable to upload image in Laravel

I am working on laravel 5.3.30 and using image intervention helper for uploading image. I am getting error "NotWritableException in Image.php line 143: Can't write image data to path (/home/test/Desktop/Laravel/blog/public/images/)" while uploading image. I have set appropriate permission to the directory but still am not able to upload image.

Code to upload image file:

if($request->hasFile('featured_image')){
            $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 checked the solutions online but none it worked. Please correct me if I am doing something wrong. Thanks in advance.




via vivek321

Advertisement