dousi6192 2015-09-07 16:54
浏览 589
已采纳

mkdir():许可Laravel

I'm running the following script for an image upload in a server and getting the following error while it works perfectly on the localhost.

Code

$user_id = Auth::id();
$logicpath = 'userdp/' . $user_id . '/';
$pubpath = 'userdp/' . $user_id . '/' . $dpFile;
$path = '/userdp/' . $user_id . '/' . $dpFile;

if (!file_exists($logicpath)) {
     mkdir($logicpath, 0777, true);
}

Error

ErrorException in UploadController.php line 605: mkdir(): Permission denied

at HandleExceptions->handleError('2', 'mkdir(): Permission denied', '/var/www/html/laravel/app/Http/Controllers/UploadController.php', '605', array('dp' => object(UploadedFile), 'ext' => 'jpg', 'img' => object(Image), 'mime' => 'image/jpeg', 'width' => '200', 'height' => '200', 'fileSize' => '17152', 'dpFile' => 'f12f298ab18d58a59c4ed8a589cd1cdc.jpg', 'user_id' => '1', 'logicpath' => 'userdp/1/', 'pubpath' => 'userdp/1/f12f298ab18d58a59c4ed8a589cd1cdc.jpg', 'path' => '/userdp/1/f12f298ab18d58a59c4ed8a589cd1cdc.jpg'))

I tried chmod 777 public and restarted the server. But it didn't work.

  • 写回答

6条回答 默认 最新

  • dongzhan5943 2015-09-07 16:59
    关注

    You have to perform chmod recursively to make sure all subdirectories also carry the same permissions. Try running this instead:

    chmod -R 777 
    

    Now while this will fix your issue, you should definitely read up on the problems that arise with setting the above permissions as this link posted in comments below shows. Ill post here as well:

    http://stackoverflow.com/a/11271632/2790481

    EDIT: This should only be done within the Laravel storage dir within /var/www/html/laravel/storage, for example and never be done at the system level. I forgot to mentioned that originally, hence all the downvotes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器