Created
July 29, 2013 00:27
-
-
Save KensakuKOMATSU/6101434 to your computer and use it in GitHub Desktop.
(File System APIの)imgファイルをxhr2でサーバーにuploadするスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("<canvas>").appendTo("body"); | |
var canvas = $("canvas")[0] | |
, ctx = canvas.getContext('2d') | |
canvas.width = 640, canvas.height = 480; | |
for(var i = 0, l = ent.length; i < l; i++) { | |
var imgURL = ent[i]; | |
var img = new Image(); | |
img.src = imgURL; | |
img.onload = function(e){ | |
console.log(this.src) | |
ctx.drawImage(this, 0, 0); | |
var dataURL = canvas.toDataURL(); | |
console.log(dataURL); | |
var name_ = this.src.split("/").slice(-1)[0] | |
$.post('http://localhost:3000/upload', {name:name_, data: dataURL}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment