QRコード生成して、ダウンロードするシステムを作りました
http://felica.boy.jp/api/qrcord.html
ダウンロードフォルダに自動保存されます。
記述ミスとかで30分くらいかかりました・・・
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>QRコード</title> </head> <body> <p>QRコードにしたい文字を入力してください。</p> <form action="qrcord.php" method="get"> キーワード:<input type="text" name="keyword" size="40"> <input type="submit" value="送信"> </form> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>QRコード</title> </head> <body> <p>生成されたQRコード</p> <?php $keyword = $_GET["keyword"]; $keywordurl = urlencode($keyword); $url = "http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=$keywordurl"; ?> <img src="<?php echo $url?>"> <form method="get" action="put.php"> <input type="hidden" name="url" value="<?php echo $url?>"> <input type="submit" value="ダウンロード"> </form> </body> </html>
<?php $file = $_GET["url"]; $fullpath = $file; $filename = 'qr.png'; header("Content-type: image/jpeg"); header("Content-Disposition: attachment; filename=$filename"); readfile($fullpath); ?>