我知道这是一个非常普遍的问题,我已经尝试了很多答案,但它并没有奏效。
这是我的代码
if(Input::hasFile('image_small')){
$image = Input::file('image_small');
$filename = $image->getClientOriginalName();
if (!File::exists(public_path('images/album/small/'.$albumcode.'/'.$filename))){
$path = public_path('images/album/small/'.$albumcode);
// dd(public_path('images/album/'.$albumcode));
File::makeDirectory(public_path('images/album/'.$albumcode));
Image::make($image->getRealPath())->resize(256,256)->save($path.'/'.$filename);
$album->album_art = 'images/album/small/'.$albumcode.'/'.$filename ;
}
}
无法将图像数据写入路径 (/var/www/madmuziktest/public/images/album/small/MAD_ALBUM-2016-0001/xxxx.jpg)
在我的公共文件夹中
我有777 /公共/图像/专辑/小
和775 for / public / images
Laravel.log
[2016-06-01 09:47:22] local.ERROR: exception 'Intervention\Image\Exception\NotWritableException' with message 'Can't write image data to path (/var/www/madmuziktest/public/images/album/small/MAD_ALBUM-2016-0001/xxxx.jpg)' in /var/www/madmuziktest/vendor/intervention/image/src/Intervention/Image/Image.php:143
Stack trace:
#0 /var/www/madmuziktest/app/Http/Controllers/AdminController.php(177): Intervention\Image\Image->save('/var/www/madmuz...')
#1 [internal function]: App\Http\Controllers\AdminController->postUploadalbum(Object(Illuminate\Http\Request))
#2 /var/www/madmuziktest/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(80): call_user_func_array(Array, Array)
#3 /var/www/madmuziktest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction('postUploadalbum', Array)
#4 /var/www/madmuziktest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(94): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\AdminController), Object(Illuminate\Routing\Route), 'postUploadalbum')
#5 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#6 /var/www/madmuziktest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#7 /var/www/madmuziktest/app/Http/Middleware/Authenticate.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#8 [internal function]: App\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#9 /var/www/madmuziktest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#10 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 /var/www/madmuziktest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#12 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))