RuinSain's avatar

Can't write image data to path (static/photos/1481902023.jpg)

Hello, for some reason i can't save pictures with the intervention tool. I have done this before, and i follow the same thing here, but now it's not being saved. The error im getting is:

NotWritableException in Image.php line 143:
Can't write image data to path (static/photos/1481902023.jpg)

here is my store function in the controller:

             $this->validate($request, array(
             'title'=>'required|max:255',
             'slug'=>'required|min:3|max:255|unique:posts',
             'body'=>'required',
             'img'=>'image',
             'desc'=>'max:255'
            ));

        $post=new Post;
        $post->title=$request->title;
        $post->slug=$request->slug;
        $post->body=$request->body;
        $post->desc = $request->desc;
        if($request->hasFile('img')){
            $image=$request->file('img');
            $imageName=time().'.'.$image->getClientOriginalExtension();
            $location='static/photos/'.$imageName;
            Image::make($image)->save($location);
            $post->image=$imageName;
        }

        $post->save();
        $post->tags()->sync($request->tags, false);
        $post->categories()->sync($request->categories, false);
        /*Session::flash('success', 'The Post Has been published!');*/
        return redirect()->route('slug', $post->slug); 

this should work like this exactly, but when i saw it did not work for some reason, i tried also the and it's not working too.

public_path()

the folder itself(static) is in the root directory of the project.

the Form view for the upload is this:

<form role="form" method="post" action="{{route('post.store')}}" enctype="multipart/form-data">
                {{csrf_field()}}

                  <div class="{{$errors->has('img')?'has-error':''}}">
                     <label class="label" for="img">העלה תמונה</label>
                     <div>
                       <input type="file" name="img" id="img" class="input" multiple="multiple">
                     </div>
                 </div>

In addition to all this, i have also checked the permission to that folder(and sub folders), and even ran the command

icacls "C:\Users\GabMic\b\static" /grant GabMic:F

What am i missing here? Ps, im using the latest version of laravel. Thanks for the help.

0 likes
1 reply

Please or to participate in this conversation.