-
-
Save ms2sato/7a18faffa0936b1fe1f1 to your computer and use it in GitHub Desktop.
PHPとAjaxでバイナリ? ref: http://qiita.com/ms2sato/items/98d1241c4af3ee4f1472
This file contains 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>Download Image</title> | |
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> | |
<script> | |
function download(){ | |
var image = new Image(); | |
image.src = 'image.php' | |
image.onload = function(){ | |
$('#result').append(image) | |
alert('downloaded'); | |
image = null; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<button onclick="download()">Download</button> | |
<div id="result"> | |
</div> | |
</body> | |
</html> |
This file contains 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
<?php | |
header('Content-type: image/jpeg'); | |
readfile('fish.jpg'); //画像用意してね | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment