- Äɲ䵤줿¹Ô¤Ï¤³¤Î¿§¤Ç¤¹¡£
- ºï½ü¤µ¤ì¤¿¹Ô¤Ï¤³¤Î¿§¤Ç¤¹¡£
[[PHP/¥µ¥ó¥×¥ë]]
½ñ¤¹þ¤ß²Äǽ¤Êupload¥Ç¥£¥ì¥¯¥È¥ê¤òÍÑ°Õ¤·¡¢¼¡¤Î¥Õ¥¡¥¤¥ë¤òÀßÃÖ¤·¤Þ¤¹¡£~
uploader.html
<html>
<head><title>File Uploader</title></head>
<body>
<h1>File Uploader</h1>
<form method="post" enctype="multipart/form-data" action="uploader.php">
<input type="file" name="upfile">
<input type="submit" value="upload">
</form>
</body>
</html>
uploader.php
<html>
<head><title>File Uploader</title></head>
<body>
<h1>File Uploader</h1>
<?php
define("UPLOAD_DIRECTORY", "./upload/");
$fname = $_FILES['upfile']['name'];
if (move_uploaded_file($_FILES['upfile']['tmp_name'], UPLOAD_DIRECTORY . $fname)) {
print("<b>" . $fname . "</b> uploaded!");
} else {
print("<b>" . $fname . "</b> upload failed ...<br />" . $_FILES['upfile']['error']);
}
?>
</body>
</html>