Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/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 对数组上的成员函数getRealPath()的调用_Laravel - Fatal编程技术网

Laravel 对数组上的成员函数getRealPath()的调用

Laravel 对数组上的成员函数getRealPath()的调用,laravel,Laravel,我正在尝试上载多个文件.mp3,但不幸的是,调用数组上的成员函数getRealPath()时遇到错误,但除音频文件外,所有数据都已成功插入 控制器 public function store(Request $request) { foreach ($request->title as $key => $value) { $audiodetail = new AudioDetail; $extension = Str::random(4

我正在尝试上载多个文件.mp3,但不幸的是,调用数组上的成员函数getRealPath()时遇到错误,但除音频文件外,所有数据都已成功插入

控制器

public function store(Request $request)
{          
  foreach ($request->title as $key => $value) {
      $audiodetail = new AudioDetail;
      $extension = Str::random(40) . ".mp3";
      $audiodetail->audio_file = Storage::disk('audiofile')->putFileAs('',$request->audio_file, $extension);
      $audiodetail->title = $value;
      $audiodetail->audio_id = $request->audio_id;
      $audiodetail->save();
   }
}

请添加刀片表单的片段。您在哪里使用
getRealpath()
?在您的代码段中没有提到这一点,谢谢大家,我只需要传递key$request->audio_file[$key]就可以了