解决cookie过大问题

1、html代码;
<p> 
 <form align="left" ng-submit="uploadAndSubmit()">
  <input id="ipt_file" class="btn btn-default" type="file" name="file"/> 
  <input type="submit"  class="btn btn-default" value="Load"/> 
  </form>
  <div align="left" >Progessing (in Bytes):{{bytesRead}} / {{bytesTotal}} 
  </div>
</p>
2、js代码;
$scope.uploadAndSubmit=function(f)
 { 
var file = $('#ipt_file').prop('files')[0];// ;f.files[0]; // try sending 
var reader = new FileReader(); 
reader.onloadstart = function()
        {  // 这个事件在读取开始时触发
$scope.bytesTotal = file.size;
        } 
reader.onprogress = function(p)
        {  // 这个事件在读取进行中定时触发 //console.log("onprogress"); 
 $scope.bytesRead = p.loaded; 
} 
reader.onload = function(event) 
        { 
 // 这个事件在读取成功结束后触发
 //console.log("load complete"); 
 var contents = event.target.result;//在事件处理器中可以通过event.target来获得FileReader实例,而且它推荐这样使用,而  不是直接使用reader变量。result属性包含读取成功时的文件内容和读取失败时的错误信息。
//console.log("contents");
 $scope.filecontents = JSON.parse(contents);
 $scope.strchartparams = $scope.filecontents;
} 
 reader.readAsBinaryString(file); 
};
$scope.strategyParamSaveClick = function()
        {
  ipCookie( 'strchartparams' , $scope.strchartparams, $scope.cookie_exp_date ) ;
  var a ={qry_type:"saveparams",file_content:$scope.strchartparams};
  $http.post(com_root,a);
};
3、后台c++代码;
void MonitorServerApp::saveparams(Json::Value &p)
{
std::string path = conf().get("config.cookies", "C:\\params\\abc.text");
Json::FastWriter jw;
std::string wr = jw.write(p);
std::cout << jw.write(p) << std::endl;
std::ifstream ifs(path);
namespace fs = boost::filesystem;
fs::path ps(path);
std::string dir = ps.parent_path().string();
bool hasdir = boost::filesystem::is_directory(dir);  //判断文件夹是否存在
if (hasdir == false)
{
fs::create_directories(dir);
}
std::ofstream fout(path);
fout << wr;
fout.close();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值