Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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
Php 当我尝试存储文件时';t将其存储在storage\app\public中_Php_Html_Laravel - Fatal编程技术网

Php 当我尝试存储文件时';t将其存储在storage\app\public中

Php 当我尝试存储文件时';t将其存储在storage\app\public中,php,html,laravel,Php,Html,Laravel,我的问题是store函数没有将歌曲存储在storage/app/public中 它将其存储在存储/应用程序中,因此我无法链接它,也无法播放歌曲 我曾尝试在store函数中编写public dir,但当我尝试播放歌曲时,他没有看到文件,因为public dir位于 路径如下: 控制员: public function store(Request $request) { $song = $request->the_song->store('songs');

我的问题是store函数没有将歌曲存储在storage/app/public中 它将其存储在存储/应用程序中,因此我无法链接它,也无法播放歌曲

我曾尝试在store函数中编写public dir,但当我尝试播放歌曲时,他没有看到文件,因为public dir位于 路径如下:

控制员:

  public function store(Request $request)
  {
     $song = $request->the_song->store('songs');

     $music = Music::create([
        'sound'=> $song,
        'name'=> $request->name
     ]);

     session()->flash('success', 'The Song Successfully Saved');
     return redirect(route('music.index'));

   }
播放歌曲:

<audio controls autoplay>

  <source src="{{ asset($song->sound) }}" type="audio/ogg">
  <source src="{{ asset($song->sound) }}" type="audio/mpeg">

</audio>


默认情况下,Laravel使用
本地文件系统磁盘(请参阅
config/filesystems.php
)。要将其保存在
public
中,您必须明确使用它:

$song = $request->the_song->store('songs', 'public');
以及在检索文件时:

Storage::disk('public')->url($song->sound)

或者您也可以将默认磁盘设置为
public

是否运行了
php artisan storage:link
?将此
更改为
歌曲
存储的配置是什么样子的?在Larvel文件中可以是。您是否检查过您的文件是否保存为公共文件?