I am trying to make a web page where I can download some files using a cgi-download. I found an example in the flash.js.
What I want - to run a fs.exec that will generate a file that can be obtained in the browser. How can i do this?
This is my attempt:
handleReport: function(ev) {
fs.exec('/bin/report',null);
var form = E('form', {
'method': 'post',
'action': L.env.cgi_base + '/cgi-download',
'enctype': 'application/x-www-form-urlencoded'
}, [
E('input', { 'type': 'hidden', 'name': 'sessionid', 'value': rpc.getSessionID() }),
E('input', { 'type': 'hidden', 'name': 'path', 'value': '/tmp/report.tar.gz' }),
E('input', { 'type': 'hidden', 'name': 'filename', 'value': 'report.tar.gz' })
]);
ev.currentTarget.parentNode.appendChild(form);
form.submit();
form.parentNode.removeChild(form);
},
render: function() {
...
o = s.option(form.Button, 'dl_report',_(' '));
o.inputstyle = 'action important';
o.inputtitle = _('Generate archive');
o.onclick = this.handleReport;
return m.render();
},
On the first click, I get error:
"Failed to stat requested path: No such file or directory"
The second click on the button is successful, I can upload the file.
I think that the problem is that the file does not have time to be formed the first time.
P.S.: Sorry for my english and js