As far as I read the documentation of both casperjs and phantomjs, direct file representations are not allowed. You can use curl as shown below:
curl http://some.testserver.com/post.php \ -F file_input=@ /path/to/my/file.txt \ -F "text_field=Some Text Here" \ -F some_number=1234
However, you can open a POST request on casperjs:
casper.start(); casper.open('http://some.testserver.com/post.php', { method: 'post', data: { 'title': 'Plop', 'body': 'Wow.' }, headers: { 'Content-type': 'multipart/form-data' } }); casper.then(function() { this.echo('POSTED it.'); }); casper.run();
Here is the relevant documentation:
http://docs.casperjs.org/en/latest/modules/casper.html#open
source share