File laravel upload mp3未定义变量
上传MP3文件时会出现一个未定义的变量错误,其他音频文件工作正常,并且与图像、PDF和所有普通扩展完美配合!!这有点奇怪 如果有人能帮上忙,我将不胜感激。。 我不认为File laravel upload mp3未定义变量,file,variables,audio,upload,laravel-5.4,File,Variables,Audio,Upload,Laravel 5.4,上传MP3文件时会出现一个未定义的变量错误,其他音频文件工作正常,并且与图像、PDF和所有普通扩展完美配合!!这有点奇怪 如果有人能帮上忙,我将不胜感激。。 我不认为mime类型是问题所在,我已经尝试了audio\mp3和audio\mpeg以及symphony中针对mp3 mime的常见错误中所述的更多内容,但给出了相同的错误 轨道控制器 protected function create(Request $r, $slug) { $album = Album::where('
mime类型是问题所在,我已经尝试了audio\mp3
和audio\mpeg
以及symphony中针对mp3 mime的常见错误中所述的更多内容,但给出了相同的错误
轨道控制器
protected function create(Request $r, $slug)
{
$album = Album::where('slug', $slug)->first();
$artist = Artist::find($album->artist_id)->get();
$is = range(0,$r->ii);
foreach ($is as $i) {
if($r->hasfile('file'.$i)){
$file = $r->file('file'.$i);
$filename = $album->id . $r['name'.$i] . "." . $file->getClientOriginalExtension();
$file = Storage::putFileAs( 'tracks', $r->file('file'.$i), $filename);
$file = $filename;
}
$track[$i] = $album->tracks()->create(
[
'name' => $r['name'.$i],
'slug' => $r['name'.$i],
'album_id' => $album->id,
'artist_id' => $album->artist_id,
'track_pic' => $album->album_pic,
'file' => $file,
'release_date' => $album->release_date,
]);
}
return redirect('/album'.'/'.$album->slug);
}
创建轨迹视图
<form class="form-horizontal" role="form" method="POST" action="{{ route('track.add', $slug) }}" enctype="multipart/form-data">
{{ csrf_field() }}
<table class="table table-hover" id="tab_logic">
<tbody>
<tr id='addr0'>
<td width="70%">
<input type="text" name='name0' placeholder='Name' class="form-control"/>
</td>
<td width="30%">
<center><label class="btn btn-default btn-round"><input type="file" name='file0' style="display:none"/><span class="glyphicon glyphicon-folder-open"></span></label></center>
</td>
</tr>
<tr id='addr1'></tr>
</tbody>
</table>
<a id="add_row" class="btn btn-primary btn-round btn-icon pull-left"><span class="glyphicon glyphicon-plus"></span></a>
<a id='delete_row' class="btn btn-primary btn-round btn-icon pull-right"><span class="glyphicon glyphicon-minus"></span></a>
{{-- Loop Counter before submit --}}
<input type="hidden" id="counter" name="ii" value="">
<!-- Submit -->
<center>
<button type="submit" class="btn btn-primary">
Add
</button>
</center>
<!-- End Submit -->
</form>
{{csrf_field()}}
{{--提交之前的循环计数器--}
添加
哪个变量未定义?日志是否显示错误调度在哪一行?变量是TrackController未定义变量:file
第72行中规定的file
,具体是通过创建方法'file'=>$file,
at HandleExceptions->handleError将文件添加到db中(8,'Undefined variable:file','C:\\xampp\\htdocs\\tests\\laravel\\sys06\\app\\Http\\Controllers\\TrackController.php',72,TrackController.php(第72行)中的数组('r'=>object(请求),'slug'=>First-Album','Album'=>object(Album),'artist'=>object(Collection),'is'=>array(0),'i'=>0))