Downloading files can be done via AJAX (with xhr2 - if you need to support older browsers, use something like jQuery-File-Upload ; a good tutorial here is about using it only to make part of the download, and not use the Blueimp interface. ) This is due to the fact that the "no manual filing form" part of your question. You still need to interact with the file upload element to select the file, and that is where you use page.uploadFile() .
To do this exclusively from JavaScript, without “interacting with any element on the page”, you can use page.evaluate () to run some custom JavaScript. Then he can use the File Reader API to find the file on the local disk, save it in the blob, and then load this block using AJAX. WebKit in PhantomJS (roughly equivalent to Chrome 13) should work, as the FileReader API seems to exist with Chrome 6.
(BTW, if all you wanted to do was upload the file to the server using a headless script, PhantomJS is full and you can use curl . But I guess you want to use PhantomJS for some other reason!)
source share