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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog