尝试使用此表单上传文件...
{{ form_model(video, {'url': 'video/subtitle', 'files': 'true'}) }}
{{ form_hidden('id') }}
{{ form_file('name', '', {class: 'form-control'}) }}
{{ form_submit('ADD', {class: 'btn btn-lg btn-success btn-block'}) }}
{{form_close()}}
表单URI的我的控制器
public function postSubtitle() {
$video = Video::where('user_id', '=', Auth::id())->find(Input::all('id'));
$typ = Input::all();
print_r($typ); print_r(Input::file('name'));
}
仅返回:Array ();
答案 0 :(得分:0)
您的表单应如下所示
{{ Form::model(<VIDEO MODEL HERE>, ['url' => 'video/subtitle', 'files' => true]) }}
{{ Form::file('name', ['class' => 'form-control'] }}
{{ Form::submit('ADD', ['class' => 'btn btn-lg btn-success btn-block'] }}
{{ Form::close() }}
你的控制器看起来应该是这样的
public function postSubtitle() {
$fileName = Input::file('name')->getClientOriginalName();
return View::make('<SOME VIEW>')->withFile($fileName);
}