コメント |
[[file_upload_html.php]]
@DIV
<?php
session_cache_limiter('nocache');
session_start();
header( "Content-Type: text/html; charset=utf-8" );
if ( $_SERVER['REQUEST_METHOD'] == "POST" ) {
$upload = realpath ( '.' );
$upload .= ( DIRECTORY_SEPARATOR . $_FILES['target']['name'] );
if ( move_uploaded_file(
$_FILES['target']['tmp_name'], $upload ) ) {
$_POST['result'] = "アップロードに成功しました";
}
else {
$_POST['result'] = "アップロードに失敗しました";
}
}
else {
$_POST['result'] = "POST メソッドを使用して下さい";
}
$_POST['files'] = $_FILES;
$json = json_encode($_POST, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE );
?>
<script>
var json = <?= $json ?>;
parent.toastr.info(json.files.target.name + " がアップロードされました");
parent.toastr.info("ファイルサイズ : " + json.files.target.size);
</script>
@END |