Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel Storage::disk('local')->put在项目文件之外创建一个文件_Laravel_Docker_Storage - Fatal编程技术网

Laravel Storage::disk('local')->put在项目文件之外创建一个文件

Laravel Storage::disk('local')->put在项目文件之外创建一个文件,laravel,docker,storage,Laravel,Docker,Storage,我正在和docker一起运行我的项目。 我正在使用这个函数 Storage::disk('local')->put("/algorithms/".$this->algorithm_id."/newfile.csv", $csv_newfile->__toString()); 我想将此文件存储为var/www/html/Laravel/resources/app/algorithms/algorithm\u id/newfile 但它将它存储在项目文件夹的上一个目录中。

我正在和docker一起运行我的项目。 我正在使用这个函数

   Storage::disk('local')->put("/algorithms/".$this->algorithm_id."/newfile.csv", $csv_newfile->__toString());
我想将此文件存储为var/www/html/Laravel/resources/app/algorithms/algorithm\u id/newfile 但它将它存储在项目文件夹的上一个目录中。 所以 我的项目正在进行中 /var/www/html/Laravel 但是它在/var/www/html/algorithms/algorithm\u id/newfile中创建了这个文件 我可能已经在/var/www/html中设置了projects根目录,但是我找不到我在哪里做的。 有人能解释一下是什么问题吗

这是我的/config/filesystems.php文件

<?php

])

我遇到了一个与你类似的问题。以下是对我有效的解决方案:

创建要放置在目录中的新磁盘

'web_site_root' => [
            'driver' =>'local',
            'root' => base_path();
        ]
您想删除第一个/

守则:

   Storage::disk('web_site_root')->put("algorithms/".$this->algorithm_id."/newfile.csv", $csv_newfile->__toString());


我不知道为什么,但不知怎么的,第一个/做了这个文件,在我的情况下,要保存在根目录中。

请查看config/filesystems.php上的存储配置。这将取决于您为config/filesystems.php中的本地存储驱动程序设置的根目录。问题是,您指的是var/www/html/Laravel/resources/app/algorithms/algorithm\u id/newfile中的存储而不是资源吗?您的根目录是本地的吗存储驱动程序是存储路径“app”,意思是var/www/html/Laravel/storage/app,因此理想情况下不应将其存储在Laravel中root@mihirBhende对
   Storage::disk('web_site_root')->put("algorithms/".$this->algorithm_id."/newfile.csv", $csv_newfile->__toString());