修改文件上传
This commit is contained in:
1 parent
bff685dce9
commit
0067a3bc98
7 files changed
+32
-67
No files matched your search
@@ -270,7 +270,7 @@ class Index extends Base
|
||||
|
||||
// 获取表单上传文件
|
||||
$file = request()->file('file');
|
||||
halt($file);
|
||||
|
||||
// 上传文件并返回结果
|
||||
$data = upload($list,$file,true);
|
||||
|
||||
|
||||
@@ -36,13 +36,13 @@ layui.use('upload', function(){
|
||||
,url: "{:url('upload')}" //上传接口
|
||||
,done: function(res){
|
||||
if(res.val == 1){
|
||||
$('#url').val('..\\public\\uploads\\chengji\\' + res.url);
|
||||
$('#url').val(res.url);
|
||||
}
|
||||
layer.msg(res.msg);
|
||||
}
|
||||
,data: {
|
||||
text: '考试成绩'
|
||||
,serurl:'..\\public\\uploads\\chengji\\'
|
||||
,serurl:'chengji\\'
|
||||
|
||||
}
|
||||
,acceptMime:'.xls,.xlsx'
|
||||
|
||||
+12
-4
@@ -206,11 +206,15 @@ function teacherNames($list = array())
|
||||
*/
|
||||
function upload($list,$file,$isSave=false)
|
||||
{
|
||||
// 声明默认目录
|
||||
$myrul = '..\public\uploads\\';
|
||||
|
||||
// 实例化文件数据模型
|
||||
$field = new \app\system\model\Fields;
|
||||
|
||||
// 移动到框架应用根目录/uploads/ 目录下
|
||||
$info = $file->move($list['serurl']);
|
||||
$info = $file->move($myrul.$list['serurl']);
|
||||
|
||||
|
||||
// 如果上传成功
|
||||
if(!$info){
|
||||
@@ -219,12 +223,16 @@ function upload($list,$file,$isSave=false)
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 成功上传后 获取上传信息
|
||||
$list['category'] = $info->getExtension();
|
||||
$list['url'] = $info->getSaveName();
|
||||
$list['url'] = $list['serurl'].$info->getSaveName();
|
||||
$list['newname'] = $info->getFilename();
|
||||
$list['hash'] = $info->hash('sha1');
|
||||
$list['userid'] = session('userid');
|
||||
$list['oldname'] = $info->getInfo('name');
|
||||
$list['fieldsize'] = $info->getInfo('size');
|
||||
|
||||
|
||||
// 如果需要保存文件
|
||||
@@ -237,7 +245,7 @@ function upload($list,$file,$isSave=false)
|
||||
$data = array(
|
||||
'msg'=>'上传成功'
|
||||
,'val'=>true
|
||||
,'url'=>$list['url']
|
||||
,'url'=>$myrul.$list['serurl'].$info->getSaveName()
|
||||
);
|
||||
}else{
|
||||
$data = array(
|
||||
@@ -249,7 +257,7 @@ function upload($list,$file,$isSave=false)
|
||||
$data = array(
|
||||
'msg'=>'上传成功'
|
||||
,'val'=>true
|
||||
,'url'=>$list['url']
|
||||
,'url'=>$myrul.$list['serurl'].$info->getSaveName()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loaded 3 of 7 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user