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.
0 提建议
邀请回答
编辑 收藏 删除 结题 收藏 举报
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);
本回答被题主选为最佳回答
, 对您是否有帮助呢?
本回答被专家选为最佳回答
, 对您是否有帮助呢?
本回答被题主和专家选为最佳回答
, 对您是否有帮助呢?
举报
按下Enter换行,Ctrl+Enter发表内容
查看更多回答(0条)