コメント |
@SHOW
https://developer.mozilla.org/ja/docs/Web/API/File(File オブジェクト)
https://developer.mozilla.org/ja/docs/Web/Guide/Using_FormData_Objects(FormData オブジェクト)
https://developer.mozilla.org/ja/docs/Web/API/FileReader(FileReader オブジェクト『ここでは画像表示で使用』)
@END
@SHOW
https://lh3.googleusercontent.com/-sJ5b3H7Lns0/WUQNZa-MnYI/AAAAAAAAk0U/oMS8OPORraY8OQIQ9jM98ZVh5gNJrAtDACHMYBhgL/s573/_img.png
ブラウザ側では、HTML のフォームのみでファイルを選択して送信します。
サーバ側は PHP でファイルを保存し、結果を JavaScript で返します。
ブラウザへの送信は、元のページに設置した IFRAME 内に送るので、ページがロードされると、parent となる元の画面に JavaScript でメッセージを表示します
@c:red(※ IFRAME 内は同一ドメインである必要があります)
@END
@DIV
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta content="width=device-width initial-scale=1.0 minimum-scale=1.0 maximum-scale=1.0 user-scalable=no" name="viewport">
<title>HTML 基本テンプレート</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link id="link" rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.3/toastr.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.3/toastr.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<!-- 共通の表示 -->
<link rel="stylesheet" href="common.css">
<!-- CSS の指定 -->
<style>
/* PC 用の表示 */
@media screen and ( min-width:480px ) {
#content {
margin: 20px;
}
}
/* スマホ用の表示 */
@media screen and ( max-width:479px ) {
#content {
margin: 0px;
}
body {
width: 100%!important;
margin: 0px;
}
.unit {
width: 100%;
}
}
</style>
<script>
// 簡易的なスマホチェックを jQuery のプロパティとして登録
jQuery.isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
if ( $.isMobile ) {
// スマホの場合は表示画面下の中央
toastr.options.positionClass = "toast-bottom-center";
}
$(function(){
// このページ自身の QRコードの表示
$('#qrcode')
.css({ "margin" : "20px" })
.qrcode({width: 160,height: 160,text: location.href });
});
</script>
</head>
<body>
<div id="head">
<div id="title">
<a href="./">HTML 基本テンプレート</a>
</div>
</div>
<div id="content">
<form target="upload" enctype="multipart/form-data" action="../upload/file_upload_html.php" method="POST">
<input name="target" type="file" class="btn btn-info">
<input type="submit" value="ファイルを送信" class="btn btn-success ">
</form>
</div>
<div id="qrcode"></div>
<iframe src="about:blank" name="upload" style="display:none;"></iframe>
</body>
</html>
@END
[[common.css]]
@DIV
@charset "UTF-8";
/* 共通の表示 */
* {
font-size: 16px;
font-family: "ヒラギノ角ゴPro W6","Hiragino Kaku Gothic Pro W6","メイリオ",Meiryo,"MS Pゴシック",Verdana,Arial,Helvetica,sans-serif;
}
#head {
background-color: #404040;
padding: 10px 0 10px 25px;
}
#head * {
color: #ffffff;
}
@END |