function uploadFile(){
if(!checkImgType($("#file"))){
return false;
}else if(!checkSize($("#file"))){
return false;
}
$.ajaxFileUpload({
url:contextPath + '/editor/uploadJson/upload',
secureuri:false,
fileElementId:'file',
dataType: 'json',
error: function (data, status, e){
alert(data);
},
success: function (data, status){
if(status!="success"){
alert("仅支持RAR格式,大小不超过5M");
}else{
alert("上传成功");
var path = data.url.split("photo/");
var contractPath = path[path.length-1];
vueEdit.entity.contractPath = contractPath;
}
}
});
}
function checkImgType(ths) {
try {
var obj_file = $(ths).get(0).files;
for(var i=0;i<obj_file.length;i++){
if (!/\.(RAR)$/.test(obj_file[i].name.toUpperCase())) {
alert("仅支持RAR格式");
$(ths).val("");
return false;
}
}
} catch (e) {
}
return true;
}
var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
function checkSize(target){
var fileSize = 0;
fileSize = target[0].files[0].size;
var size = fileSize / 1024 / 1024;
if (size > 5) {
alert("附件不能大于5M");
var obj = document.getElementById('file') ;
obj.outerHTML=obj.outerHTML;
return false;
}else{
return true;
}
}
if(!checkImgType($("#file"))){
return false;
}else if(!checkSize($("#file"))){
return false;
}
$.ajaxFileUpload({
url:contextPath + '/editor/uploadJson/upload',
secureuri:false,
fileElementId:'file',
dataType: 'json',
error: function (data, status, e){
alert(data);
},
success: function (data, status){
if(status!="success"){
alert("仅支持RAR格式,大小不超过5M");
}else{
alert("上传成功");
var path = data.url.split("photo/");
var contractPath = path[path.length-1];
vueEdit.entity.contractPath = contractPath;
}
}
});
}
function checkImgType(ths) {
try {
var obj_file = $(ths).get(0).files;
for(var i=0;i<obj_file.length;i++){
if (!/\.(RAR)$/.test(obj_file[i].name.toUpperCase())) {
alert("仅支持RAR格式");
$(ths).val("");
return false;
}
}
} catch (e) {
}
return true;
}
var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
function checkSize(target){
var fileSize = 0;
fileSize = target[0].files[0].size;
var size = fileSize / 1024 / 1024;
if (size > 5) {
alert("附件不能大于5M");
var obj = document.getElementById('file') ;
obj.outerHTML=obj.outerHTML;
return false;
}else{
return true;
}
}