学生信息模板上传

This commit is contained in:
cxdbz committed 2018-11-05 21:54:53 +08:00
1 parent fb64ff2556
commit dbc0dc348f
5 files changed
+12 -13

No files matched your search

+3 -4
View File
@@ -10,11 +10,9 @@ use PhpOffice\PhpSpreadsheet\IOFactory;
class Myexcel
{
// 读取电子表格
public function readExcel($filename = '/public/upload/Book1.xls')
{
/**读取数据**/
public function readXls($filename){
$path = $filename;
dump($path);
setlocale(LC_ALL, 'zh_CN'); //csv中文乱码
$inputFileType = IOFactory::identify($path);
$excelReader = IOFactory::createReader($inputFileType);
@@ -29,6 +27,7 @@ class Myexcel
}
// 生成电子表格
public function outExcel()
{
+4 -4
View File
@@ -250,9 +250,9 @@ class Student extends Base
$excel = new Myexcel();
// 读取表格数据
$stuinfo = $excel->readExcel($list['url']);
$stuinfo = $excel->readXls($list['url']);
dump($stuinfo)
dump($stuinfo);
@@ -272,7 +272,7 @@ class Student extends Base
// 获取表单上传文件 例如上传了001.jpg
$file = request()->file('file');
// 移动到框架应用根目录/uploads/ 目录下
$info = $file->move( '..\uploads\teacher');
$info = $file->move( '..\uploads\student');
if($info){
// 成功上传后 获取上传信息
$list['category'] = $info->getExtension();
@@ -282,7 +282,7 @@ class Student extends Base
//将文件信息保存
$data = Fields::create($list);
$data ? $data = array('msg'=>'上传成功','val'=>true,'url'=>'..\uploads\teacher\\'.$list['url']) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null);
$data ? $data = array('msg'=>'上传成功','val'=>true,'url'=>'..\uploads\student\\'.$list['url']) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null);
}else{
// 上传失败获取错误信息
$data = array('msg'=>$file->getError(),'val'=>false,'url'=>null);
@@ -21,7 +21,7 @@
</div>
</div>
</div>
<form action="/teacher/createall" method="POST" class="form form-horizontal" id="form-member-add">
<form action="/student/createall" method="POST" class="form form-horizontal" id="form-member-add">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>文件路径:</label>
<div class="formControls col-xs-8 col-sm-9">
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff. Show more