Skip to content

Instantly share code, notes, and snippets.

@otiai10
Last active December 22, 2015 20:19
Show Gist options
  • Save otiai10/6525286 to your computer and use it in GitHub Desktop.
Save otiai10/6525286 to your computer and use it in GitHub Desktop.
かなりいいところまで来てる

server console

# 試験系
POST
ImmutableMultiDict([('img', <FileStorage: u'' ('application/octet-stream')>)])
<FileStorage: u'' ('application/octet-stream')>
124.35.46.4 - - [12/Sep/2013 00:28:31] "POST /upload HTTP/1.1" 500 -

# 正常系
POST
ImmutableMultiDict([('img', <FileStorage: u'sample03.png' ('image/png')>)])
<FileStorage: u'sample03.png' ('image/png')>
124.35.46.4 - - [12/Sep/2013 00:28:49] "POST /upload HTTP/1.1" 200 -

client code

        var xhr = new XMLHttpRequest();
        xhr.open('POST', 'http://myhost.com:9999/upload');

        var form = document.createElement('form');
        var input = document.createElement('input');
        input.type = 'file';
        input.name = 'img';
        //input.value = dataUrl;
        form.appendChild(input);
        var data = new FormData(form);

        xhr.send(data);

        xhr.addEventListener('load',function(ev){
            if(xhr.status !== 200) return alert(xhr.status);
            alert(xhr.response);
        });
@otiai10
Copy link
Author

otiai10 commented Sep 12, 2013

@otiai10
Copy link
Author

otiai10 commented Sep 12, 2013

アカンこれ無理な奴や
http://oshiete.goo.ne.jp/qa/1794854.html

@otiai10
Copy link
Author

otiai10 commented Sep 12, 2013

input[type=file]じゃなくて、バイナリで攻める
http://d.hatena.ne.jp/yoya/20130425/jsbin

@otiai10
Copy link
Author

otiai10 commented Sep 12, 2013

chrome.tabs.captureVisibleTabがbinary返してくれればよかったのに

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment