PHP を使用してファイルをアップロードする標準的な方法に加えて、HTML5 の input 要素で multiple="true"(要するに、ファイル選択ダイアログでファイルを複数選択が可能になります) を指定したサンプルです Google Chrome
Firefox
IE10
![]()
<? header( "Content-Type: text/html; Charset=utf-8" ); header( "pragma: no-cache" ); header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); header( "Cache-control: no-cache" ); foreach( $_POST as $Key => $Value ) { $_POST[$Key] = str_replace("\\\\", "\\", $Value ); $_POST[$Key] = str_replace("\\'", "'", $_POST[$Key] ); $_POST[$Key] = str_replace("\\\"", "\"", $_POST[$Key] ); } require_once("html_head.php"); print "<pre>"; print_r( $_FILES ); print "</pre>"; $target = $_FILES['file_1']['name']; $upload = "./upload_file/"; $upload .= $target; print $upload . "<br>"; if ( move_uploaded_file( $_FILES['file_1']['tmp_name'], $upload ) ) { print "アップロードに成功しました\n"; } else { print "アップロードに失敗しました\n"; } ?>
更新履歴 2011-05-22 : 初回投稿 2013-09-08 : IE10 でテスト( 表示等を少し変更 )
タグ:HTML5