提交 46c66848 编写于 作者: G gongfuxiang

excel上传文件错误码处理

上级 fd11a90a
......@@ -110,10 +110,11 @@ class FractionController extends CommonController
$this->error(L('common_unauthorized_access'));
}
// 文件是否上传
if(empty($_FILES['excel']['tmp_name']))
// 文件上传校验
$error = FileUploadError('excel');
if($error !== true)
{
$this->ajaxReturn(L('common_select_file_tips'), -1);
$this->ajaxReturn($error, -1);
}
// excel驱动
......
......@@ -112,10 +112,11 @@ class StudentController extends CommonController
$this->error(L('common_unauthorized_access'));
}
// 文件是否上传
if(empty($_FILES['excel']['tmp_name']))
// 文件上传校验
$error = FileUploadError('excel');
if($error !== true)
{
$this->ajaxReturn(L('common_select_file_tips'), -1);
$this->ajaxReturn($error, -1);
}
// excel驱动
......
......@@ -7,7 +7,7 @@
<div class="am-popup-bd">
<!-- win form start -->
<form class="am-form form-validation excel-form" action="{{$excel_import_form_url}}" method="POST" request-type="ajax-fun" request-value="ExcelImportCallback" enctype="multipart/form-data">
<input type="hidden" name="max_file_size" value="{{:MyC('home_max_limit_image', 2048000)}}" />
<input type="hidden" name="max_file_size" value="{{:MyC('home_max_limit_file', 51200000)}}" />
<div class="am-alert am-radius am-alert-tips m-t-0" data-am-alert>
<notempty name="excel_import_format_url">
<p class="m-b-0"><a href="{{$excel_import_format_url}}" class="cr-blue">{{:L('common_excel_format_download_name')}}</a><span class="m-r-5"></p>
......
......@@ -8,6 +8,38 @@
* @datetime 2016-12-01T21:51:08+0800
*/
/**
* [FileUploadError 文件上传错误校验]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-12T17:21:51+0800
* @param [string] $name [表单name]
* @return [mixed] [true | 错误信息]
*/
function FileUploadError($name)
{
// 是否存在该name表单
if(empty($_FILES[$name]))
{
return L('common_select_file_tips');
}
// 是否正常
if($_FILES[$name]['error'] == 0)
{
return true;
}
// 错误码对应的错误信息
$file_error_list = L('common_file_upload_error_list');
if(isset($file_error_list[$_FILES[$name]['error']]))
{
return $file_error_list[$_FILES[$name]['error']];
}
return L('common_unknown_error');
}
/**
* [LangValueKeyFlip 公共数据翻转]
* @author Devil
......
......@@ -87,6 +87,7 @@ return array(
'common_on_fill_in_the_text' => '未填写',
'common_select_file_text' => '选择文件',
'common_select_file_tips' => '请选择需要上传的文件',
'common_unknown_error' => '未知错误',
'common_library_email_empty_error' => '收件邮箱不能为空',
'common_library_content_empty_error'=> '发送内容不能为空',
......@@ -419,6 +420,18 @@ return array(
'am-badge-danger',
),
// 文件上传错误码
'common_file_upload_error_list' => array(
1 => '文件大小超过服务器允许上传的最大值',
2 => '文件大小超出浏览器限制,查看[{站点设置->文件最大限制}是否大于该值]',
3 => '文件仅部分被上传',
4 => '没有找到要上传的文件',
5 => '没有找到服务器临时文件夹',
6 => '没有找到服务器临时文件夹',
7 => '文件写入失败',
8 => '文件上传扩展没有打开',
),
// 正则
// 用户名
'common_regex_username' => '^[A-Za-z0-9_]{5,18}$',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册