js 上传和下载本地文件

function writeFile(path,data){
	var fso, f, s ; 
	 fso = new ActiveXObject("Scripting.FileSystemObject");    
	 if(isFile(path)){
		fso.DeleteFile(path);   
	}
	 f = fso.OpenTextFile(path,8,true); 
	f.WriteLine(data);   
	f.Close(); 	
		
}
function isFile(path){
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var f = fso.FileExists(path);
	return f;
}
function synchronyInfo(){
	var httpRequest = new HttpRequest("../offRegionPolice/synchronyInfo.action", "post", {
		onRequestSuccess : function(responseText) {
		if("error" == responseText){
			alert("同步出错,请重试");
		}else{
			 var tmsTaskAppInfoJsons=responseText.split("==");
			writeFile("D:\\autoData.json",tmsTaskAppInfoJsons[0]);
			writeFile("D:\\data.json",tmsTaskAppInfoJsons[1]);
			alert("同步成功!");
		}
		}
	});
	httpRequest.sendRequest(false);
}
//同步销单信息
function synchronyFinishInfo(){
		var data=readFile("D:\\finishData.json")
		var httpRequest = new HttpRequest("../offRegionPolice/synchronyFinishInfo.action", "post", {
			onRequestSuccess : function(responseText) {
			    if("" == responseText){
			    	alert("上传数据成功!");
			    	search_list_page();
			    }else{
				alert(responseText);
			    }
			}
		});
		httpRequest.addParameter("parameter['finishData']",data);
		httpRequest.sendRequest(false);
}
function readFile(path) {
	var data = new Array();
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var f = fso.OpenTextFile(path, 1);
	while (!f.AtEndOfStream) {
		var line = f.ReadLine();
		data.push(line.split("\t"));
	}
	f.Close();
	return data;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值