Reputation: 2393
I'm trying to manage my fileuploading but it seems I cant write to the folder public/uploads
.
I have write permission so I'm not sure what it can be, does somebody see a typo?
I use the intervention/image library.
My code is:
$file = Input::file($fileName);
if ($file->isValid()) {
if ($file->getMimeType() == 'image/jpeg' || $file->getMimeType() == 'image/png') {
$path = public_path("uploads", $file->getClientOriginalName());
Image::make($file->getRealPath())->resize(180, null)->save($path);
} else {
throw new FileException;
}
}
The exception thrown is:
Intervention \ Image \ Exception \ NotWritableException
Can't write image data to path (/home/vagrant/Sites/cms/public/uploads)
Upvotes: 1
Views: 2445
Reputation: 2393
I've found the typo...
I had:
$path = public_path("uploads", $file->getClientOriginalName());
Changed to:
$path = public_path("uploads/" . $file->getClientOriginalName());
Thanks for the quick answer though!
Upvotes: 5
Reputation: 3598
You need to check the permissions of the folder, and its parent folders. If you're on linux, it should be 644. The individual folder may have write access, but the parent might not; or it could be for the wrong user. Check the Ownership group too.
Upvotes: 1