日期:2014-05-16  浏览次数:20379 次

jsp 文件上传

jQuery.ajaxFileUpload({

? ? ? ? ?url:"installApk",

? ? ? ? ?secureuri:false,

? ? ? ? ?fileElementId:'installApkName',//input框的ID

? ? ? ? ?dataType: 'json',//返回数据类型

? ? ? ? ?beforeSend:function(){//上传前需要处理的工作,如显示Loading...

? ? ? ? ?},

? ? ? ? ?success: function (data, status){//上传成功

? ? ? ? jQuery('.dial').val(50).trigger('change');

? ? ? ? ? ? var resultVal = data.split(",");

? ? ? ? ? ? if(resultVal[0]=="success"){

? ? ? ? ? ? jQuery.post("checkInstall",

? ? ? ? {host_ip : host_ip,

? ? ? ? test_agent_port : test_agent_port,

? ? ? ? apkPath : resultVal[1],

? ? ? ? device_sn : device_sn

? ? ? ? },?

? ? ? ? function(data,status,resp) {

? ? ? ? jQuery('.dial').val(65).trigger('change');

? ? ? ? ? ? ? ? if(data.msg.indexOf("fail") > -1){

? ? ? ? ? ? ? ? ? ? alert("很抱歉,连接异常,请稍后重新尝试!");

? ? ? ? ? ? ? ? cancel();

? ? ? ? ? ? ? ? }

? ? ? ? if(data.msg == "Success"){

? ? ? ? appList = appList + jQuery("#installApkName").val();

? ? ? ? jQuery('.dial').val(100).trigger('change');

? ? ? ? setTimeout(function(){alert("您的已经安装成功!");

? ? ? ? cancel();},1000);

? ? ? ? ? ? }

? ? ? ? ? ? if(data.msg == "Failure"){

? ? ? ? ? ? jQuery('.dial').val(80).trigger('change');

setTimeout(function(){alert("对不起,安装失败!");cancel();},1000);

? ? ? ? ? ? ? ? }

if(data.msg == "Unsafe"){

jQuery('.dial').val(80).trigger('change');

setTimeout(function(){alert("很抱歉,您上传的应用程序是不安全的,安装失败!");cancel();},1000);

? ? ? ? ? ? ? ? }

if(data.msg == "Unavailable"){

jQuery('.dial').val(80).trigger('change');

setTimeout(function(){alert("很抱歉,您上传的应用程序文件无效,安装失败!");cancel();},1000);

? ? ? ? ? ? ? ? }

? ? ? ? },"json");

? ? ? ? ? ? }else{

? ? ? ? ? ? ? ? if(resultVal[1]=="FtpConnectionError"){

alert("很抱歉,连接异常,请稍后重新尝试!");

cancel();

? ? ? ? ? ? ? ?