I am trying to save a managed image that I click on s3.
My code that works This code saves the image directly in the public folder *
public function store(Filesystem $filesystem) { $request = Input::all(); $validator = Validator::make($request, [ 'images' => 'image' ]); if ($validator->fails()) { return response()->json(['upload' => 'false']); } $postId = $request['id']; $files = $request['file']; $media = []; $watermark = Image::make(public_path('img/watermark.png')); foreach($files as $file) { $image = Image::make($file->getRealPath()); $image->crop(730, 547); $image->insert($watermark, 'center'); $image->save($file->getClientOriginalName()); } }
What I would like to achieve is to save it in my own folder. First, what is the best place to store an image for a blog post in a repository from a public folder? But anyway, when I do this:
$image->save('blogpost/' . $postId . '/' . $file->getClientOriginalName()); // Or this $image->save(storage_path('app/blogpost/' . $postId . '/' . $file->getClientOriginalName()));
I get an error message:
in the public
NotWritableException on Image.php 138 line: cannot write image data to path (blogpost / 146 / cars / image.jpg)
or
storage path
NotWritableException on Image.php 138 line: it is not possible to write image data to the path / code / websites / blog / storage / app / blogpost / 146 / image.jpg
I tried
cd storage/app/ chmod -R 755 blogpost
And it still doesn't work
Thanks for reading this.
source share