document.getElementById('divupload').addEventListener('drop', onDrop, true)
function onDrop(event) {
event.stopPropagation();
event.preventDefault();
var file = event.dataTransfer.files[0];
var reader = new FileReader();
reader.onload = (function (aImg) {
return function (e) {
$("#imagedata").attr("src", e.target.result);
$("#HiddenFieldimagedata").val(e.target.result);
};
})($("#imagedata"));
reader.readAsDataURL(file);
}
以下為透過複製貼上取得圖檔內容
$("html").pasteImageReader(function (results) {
$("#imagedata").attr("src", results.dataURL);
$("#HiddenFieldimagedata").val(results.dataURL);
});
divupload is div
$("#imagedata") is img
$("#HiddenFieldimagedata") is asp:HiddenField