« postgre timetamp to date | メイン | 無料鍵 »
2018年08月17日
画像ペーストでデータURL取得の骨組み
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>p</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<body>
<a href="" id="ss">ここ</a>
<input type="text" name="poge" value="oo">
<script>
$("input[name=poge]").on("paste",function(e){
if (e.originalEvent.clipboardData.files.length){
console.log(e.originalEvent.clipboardData.files.length);
e.preventDefault();
let datobj = e.originalEvent.clipboardData.files[0];
console.log(datobj);
var reader = new FileReader();
reader.onloadend = function () {
$("#ss").attr({"href":reader.result});
}
reader.readAsDataURL(datobj);
}
});
</script>
</body>
</html>
投稿者 muuming : 2018年08月17日 11:33