Drag anddropfilereader
- 6. あああ&濒迟;箩补惫补蝉肠谤颈辫迟&驳迟;function init() {dandd= new Nakaji();?addEvent(window, "dragenter", dandd.dragEnter, false);vardropBox = {};dropBox= document.getElementById("dropbox");?addEvent(dropBox, "dragover", dandd.dragOver, false);addEvent(dropBox, "drop", dandd.drop, true);}?// ロード時に処理を追加window.addEventListener("load", init, false);??
- 11. drop : function(event) { // ドラッグされたデータを取得var files = event.dataTransfer.files;????var file = files[i];var reader = new FileReader(); reader.name = file.name,reader.index = i,reader.file = file; // メソッドの登録reader.addEventListener("loadend", Nakaji.prototype.buildImageListItem, false); // ファイルをdataURL形式で読み取るreader.readAsDataURL(file);??あああ
- 12. buildImageListItem : function(event) {varimgTag = $(document.createElement("img"));vardivTag = $(document.createElement("div"));varname = event.target.name;vardata = event.target.result;varfile = event.target.file;?imgTag.attr({ width: 200, height: 200,src: data });? // 先頭に追加 $("#bag").prepend(divTag.append(imgTag.fadeIn(2000)));あああ
- 16. あああ&濒迟;箩补惫补蝉肠谤颈辫迟&驳迟; // マルチパート形式で画像を保存するmultipartFormData+= '--' + boundary + '';multipartFormData += 'Content-Disposition: form-data; filename="' + file.name + '"' +'Content-Type: ' + contentType + '' +'Content-Transfer-Encoding: binary' + '' + '' +file.getAsBinary() +'--' + boundary + '--';?