V
V
Valery Khizhevsky2017-08-12 19:01:10
Laravel
Valery Khizhevsky, 2017-08-12 19:01:10

What causes an error when uploading a Laravel image?

Gives such an error.
Can't write image data to path (uploads/img.png)
Here is the code

if(Input::hasFile('file')) {
            $file = Input::file('file');
            $file = Image::make($file)->resize(300, 200)->save('uploads/img.png');
}

When in line
$file = Image::make($file)->resize(300, 200)->save('uploads/img.png');

I remove Uploads and just save it to the public folder, then everything works, how to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dave, 2017-08-12
@djay

Use absolute paths instead of relative ones (about the difference - google and read)
It should be like this
..->save(__DIR__ . '/uploads/img.png');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question