解决cookie过大问题

1、html代码;

Progessing (in Bytes):{{bytesRead}} / {{bytesTotal}}

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(); }

你可能感兴趣的:(WEB前端,c++函数)