我已经在数据库中上传了文件(多媒体文件)的路径,现在我很难将其检索到“视图”中。例如文件已上传但无法查看或播放。
我尝试了多种方法来处理它,但是没有任何效果。
这是我的秃头
<div>
@foreach ($users as $user)
Title: {{ $user->title }} <br>
By: {{ $user->author }} <br>
<audio src="{{ url('audios/') }}" controls>
</audio> <br><br><br>
@endforeach
</div>
和控制器
$audio = $request->file('audio-folktale');
$new_name = $audio->getClientOriginalName();
$location = $audio->move(public_path('audios'), $new_name);
$request->validate([
'title' => 'required:max:25',
'author' => 'required'
]);
auth()->user()->audios()->create([
'title' => $request->get('title'),
'author' => $request->get('author'),
'audio' => $request->get('audio',$location)
]);
return redirect()->route('viewAudio');
答案 0 :(得分:0)
您的查看文件是这样的:
@foreach ($users as $user)
Title: {{ $user->title }} <br>
By: {{ $user->author }} <br>
<audio src="{{ url('audios/') }}{{$user->audio}}" controls>
</audio> <br><br><br>
@endforeach