PHPとjQueryでアップロードのプログレスバーを作る方法!手順書③「作成」
フォームに呪文を追加
index.phpのフォームに以下を追加します。
<input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="任意" />
全体でこんな感じです。
index.php
<?php session_start(); require_once("common.php"); if(isset($_POST["create"])){ for($i=1;$i<=6;$i++){ $data = $_FILES["files".$i]; upload_files($data,date("YmdHis").$i,"files"); } } ?> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="some.js"></script> <script type="text/javascript" src="script.js"></script> </head> <body> <form action="index.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="example" /> <input type="file" name="files1" /><br> <input type="file" name="files2" /><br> <input type="file" name="files3" /><br> <input type="file" name="files4" /><br> <input type="file" name="files5" /><br> <input type="file" name="files6" /><br> <input type="submit" name="create" value="送信" /> </form> <div id="progress_box"> </div> </body> </html>
nameにini_get("session.upload_progress.name")で取得したINIオプションを指定するのは、アップロードの進捗を取得するという宣言です。
これがない場合、進捗情報は$_SESSIONに保存されませんので注意してください。
また。ここで指定するvalue値は任意ですが、後でここで指定したvalue値を使いますので、そのことを覚えておいてください。
今回はvalue="example"としておきました。