hiroshi3110
unread,May 19, 2011, 1:19:44 AM5/19/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to phantomjs
Hi,
I'm trying to read local file contents with phantomjs.
I attempted following script, using File API's FileReader.
========= fileread.js =========
if (phantom.state.length === 0) {
phantom.state = 1;
phantom.content = '<html><body><form><input type="file" id="foo" /></
form></body></html>';
} else {
var foo = document.getElementById('foo');
phantom.setFormInputFile(foo, 'fileId');
var file = foo.files[0];
var reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = function (evt) {
console.log(evt.target.result);
}
reader.onerror = function (evt) {
console.log("error reading file");
}
phantom.exit();
}
===========================
but, I got the error.
$ phantomjs test.js --upload-file fileId=test.js
undefined:8 ReferenceError: Can't find variable: FileReader
Current version of QtWebKit doesn't seem to have FileReader.
I hope that issue #31 - "Bleeding-edge WebKit" will solve this in the
future.
Are there any way to read local files?