//点击选择完成文件后,触发上传文件操作,将文件上传至服务器临时目录
$('.upload-real-file').off().on('change', function(){
if(!$(this).val()){
return false;
}
var responseObjId = $(this).attr('response-id');
var responseObj = $('#' + responseObjId);
$('#Form').ajaxSubmit({
url:'/aa/bb/uploadTmpApkTool',
resetForm: false,
dataType: 'json',
beforeSubmit: function(option){
window.loading = layer.load(2);
},
success: function(data, statusText){
layer.close(window.loading);
if(data.status == 1){
responseObj.html(data.apkInfoHtml);
var parentContainer = responseObj.parent().parent(),
nameContainer = parentContainer.find('.file-name-container');
nameContainer.html(data.apkName);
nameContainer.attr('title', data.apkName);
responseObj.find('.file-tmp').html(data.fileInfo); //将文件信息存放于隐藏域中,以便在提交时能找到
$(submitId).removeAttr('disabled');
}else{
layer.alert(data.info);
}
},
error: function(data){
layer.close(window.loading);
layer.alert('未知错误,请稍后再试!');
}
});
return false;//防止dialog 自动关闭
});
$apkConfig = $this->_getApkConfig();
$params = $this->getFilteredParam('get');
$subFile = $_FILES['apkToolFiles'];
$apkName = $apkInfoHtml = "";
if(empty($subFile))
{
$this->ajaxReturn(array('status' => -4, 'info' => '请选择要上传的文件'));
}
foreach ($subFile['name'] as $subKey => $subVal)
{
if ($subFile['name'][$subKey])
{
$fileData = $this->_getFileData($subFile, $subKey);
$checkData = array(
'maxSize' => $apkConfig['FILE_MAX_SIZE'],
'savePath' => $apkConfig['TMP_CHILD_PATH'],
'extArr' => array('apk'),
'releaseName' => str_replace('.apk', '', $fileData['fileName']), //特有
);
$checkResult = $this->_checkFileData($fileData, $checkData);
if ($checkResult['status'] != 1)
{
$this->ajaxReturn($checkResult);
}
//移动文件
$filePath = $checkData['savePath'] . '/' . $fileData['fileName'] . '.tmp' . genRandStr(6);;
$this->_moveUploadedFile($fileData['tmpName'], $filePath);
$apkInfo = $this->_apkParser($filePath); //解析
if($apkInfo['UMENG_CHANNEL'] != 'UMENG_CHANNEL_VALUE')
{
@unlink($filePath); //删除无效文件
$this->ajaxReturn(array('status' => 0, 'info' => "UMENG_CHANNEL的值要是 UMENG_CHANNEL_VALUE才行"));
}
$tmpFileArr['file_info'] = array(
'name' => $subFile['name'][$subKey],
'type' => $subFile['type'][$subKey],
'tmp_name' => str_replace($apkConfig['TMP_CHILD_PATH'] . '/', '', $filePath),
'error' => $subFile['error'][$subKey],
'size' => $subFile['size'][$subKey],
); //转存该值,不再重复上传文件
}
else
{
$this->ajaxReturn(array('status' => 0, 'info' => "文件不能为空"));
}
foreach ($apkInfo as $key => $val)
{
$apkInfoHtml .= "{$key}:{$val} rn";
}
$apkName = $fileData['fileName'];
$version = $apkInfo['versionName'];
}
$fileInfo = htmlspecialchars(json_encode($tmpFileArr['file_info']));
$fileInfoHtml = "<input name="apkToolFileTmp[]" value='{$fileInfo}' type="hidden"/>"; //一定要输出前使用htmlspecialchars, 否则不能正确显示页面值和获取至正确的文件信息
$this->ajaxReturn(array('status' => 1, 'info' => "上传成功", 'version' => $version, 'item' => $item, 'apkName' => $apkName, 'apkInfoHtml' => $apkInfoHtml, 'fileInfo' => $fileInfoHtml));
}
$('.upload-file-real').attr('disabled', 'disabled'); //提交表单前,禁用上传文件
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有