Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / phantomjs / lib / phantom / examples / imagebin.coffee
1 # Upload an image to imagebin.org
2
3 page = require('webpage').create()
4 system = require 'system'
5
6 if system.args.length isnt 2
7   console.log 'Usage: imagebin.coffee filename'
8   phantom.exit 1
9 else
10   fname = system.args[1]
11   page.open 'http://imagebin.org/index.php?page=add', ->
12     page.uploadFile 'input[name=image]', fname
13     page.evaluate ->
14       document.querySelector('input[name=nickname]').value = 'phantom'
15       document.querySelector('input[name=disclaimer_agree]').click()
16       document.querySelector('form').submit()
17
18     window.setTimeout ->
19       phantom.exit()
20     , 3000