3 不能上传头像,提示Can't write image data to path

[2018-09-19 14:33:48] local.ERROR: Intervention\Image\Exception\NotWritableException: Can't write image data to path (/var/www/tipask/storage/app/avatars/000/00/00/user_origin_1.jpg) in /var/www/tipask/vendor/intervention/image/src/Intervention/Image/Image.php:143

Stack trace:

#0 /var/www/tipask/app/Http/Controllers/Account/ProfileController.php(86): Intervention\Image\Image->save('/var/www/tipask...')

#1 [internal function]: App\Http\Controllers\Account\ProfileController->postAvatar(Object(Illuminate\Http\Request))

#2 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array(Array, Array)

#3 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction('postAvatar', Array)

#4 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\Account\ProfileController), Object(Illuminate\Routing\Route), 'postAvatar')

#5 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

#6 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

#7 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

#8 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

#9 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): Illuminate\Pipeline\Pipeline->then(Object(Closure))

#10 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(68): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\Account\ProfileController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'postAvatar')

#11 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'postAvatar')

#12 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))

#13 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))

#14 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

#15 /var/www/tipask/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

#16 /var/www/tipask/app/Http/Middleware/Authenticate.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))


请先 登录 后评论

最佳答案 2018-09-27 10:00

确认一下 var/www/tipask/storage 目录是否有读写权限

请先 登录 后评论

其它 4 个回答

自然而然 - 逸千程旅行https://www.cnuu.com/

我也碰到过,是权限问题,问答库网站。

请先 登录 后评论
NoneType

我也遇到了这个问题,不过确认不是目录权限的问题,同样的上传图片,上传支付码可以用,但上传头像不行。不知道你解决没有

请先 登录 后评论
曹杜军

Intervention\Image 的save()方法貌似目录不存在,则会出现这样的问题,使用前请确定上传文件的目录是否存在或者再调用save()方法前添加创建目录代码:

if(!is_dir($pathRoot.$path)){
if(!mkdir($pathRoot.$path)){
return $this->fail('缩略图上传失败!');
}
}

这样就不会有问题了

请先 登录 后评论
德宝
测试一下效果

attachments-2019-09-PJwTX8Ul5d7c688b77c8b.jpg

请先 登录 后评论