上传文件获取一直为 nu l l??
<form class="form-horizontal ajax-form" action="{{ url('UserAppConfig/update') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="col-sm-3 col-md-2 control-label no-padding-right">
App :
</label>
<div class="col-sm-9 col-md-10">
<input name="source" type="file" style="margin-top: 10px" class="col-xs-12 col-sm-5 col-md-3" >
</div>
</div>
<div class="clearfix form-actions">
<div class="col-md-offset-2 col-md-10 col-sm-offset-3 col-sm-9">
<button class="btn btn-info loading-btn" type="submit" data-loading-text="提交中...">
<i class="ace-icon fa fa-check bigger-110"></i>
提交
</button>
</div>
</div>
</form>
if($request->isMethod('POST')) {
//print_r($_FILES);
//source表单名
$file = $request->file('source');
//文件是否上传成功
if($file->isValid()) {
//取原文件名
$originalName = $file->getClientOriginalName();
//取扩展名
$ext = $file->getClientOriginalExtension();
//取文件类型
$type = $file->getClientMimeType();
//临时文件的绝对路径
$realPath = $file->getRealPath();
//定义文件名
$fileName = date("YmdHis"). '-' . uniqid(). '.' . $ext;
//uploads为config/filesystems里自定义
$bool = Storage::disk('uploads')->put($fileName, file_get_contents($realPath));
print_r($bool);exit;
}
}
return view('student.upload');
}
推荐文章: