dongyun7897 2016-01-27 14:14
浏览 162
已采纳

Laravel的Storage :: makeDirectory返回mkdir:invalid参数

So I'm trying to create a new directory in C:/..../public/videos folder when somebody uploads a video, using the following code:

if ($request->hasFile('video')) {
    $newDir = public_path('videos\\' . $story->story_id);
    Storage::makeDirectory( $newDir, 0755, true);
    $request->file('video')->move($newDir);
 }

But I get this error:

ErrorException in Local.php line 350: mkdir(): Invalid argument in Local.php line 350 at HandleExceptions->handleError('2', 'mkdir(): Invalid argument', 'C:\xampp\htdocs\qanda2\vendor\league\flysystem\src\Adapter\Local.php', '350', array('dirname' => 'C:\xampp\htdocs\qanda2\public\videos\31', 'config' => object(Config), 'location' => 'C:\xampp\htdocs\qanda2\storage\app\C:\xampp\htdocs\qanda2\public\videos\31', 'umask' => '0', 'visibility' => 'public')) at mkdir('C:\xampp\htdocs\qanda2\storage\app\C:\xampp\htdocs\qanda2\public\videos\31', '493', true) in Local.php line 350 at Local->createDir('C:\xampp\htdocs\qanda2\public\videos\31', object(Config)) in Filesystem.php line 259 at Filesystem->createDir('C:\xampp\htdocs\qanda2\public\videos\31') in FilesystemAdapter.php line 276

It seems like makeDirectory automatically adds C:\xampp\htdocs\qanda2\storage\app\ in front of my path.

Is there any workaround for this? I've been struggling with this for a while now and I can't find anything about this issue.

  • 写回答

1条回答 默认 最新

  • dongzhang6544 2016-01-27 14:23
    关注

    To create a directory, you should use File, like this:

    if ($request->hasFile('video')) {
       $newDir = public_path('videos\\' . $story->story_id);
       File::makeDirectory( $newDir, 0755, true);
       $request->file('video')->move($newDir);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理