摘要:[PHP]PHP簡易檔案上傳實作&問題
<html>
<head>
<title>File_Upload</title>
<meta http-equiv="content-type" charset="UTF-8"/>
</head>
<body>
<h1>檔案上傳</h1>
<form method="post" action="upload.php" enctype="multipart/form-data">
選擇檔案:<input id="file" name="file" type="file" />
<br />
<input type="submit" value="上傳檔案" />
</form>
</body>
</html>
<html>
<head>
<title>File_Upload</title>
<meta http-equiv="content-type" charset="UTF-8"/>
</head>
<body>
<h1>檔案上傳</h1>
<?php
if($_FILES['file']['error']>0){
echo "檔案上傳失敗";
}
move_uploaded_file($_FILES['file']['tmp_name'], 'file/'.$_FILES['file']['name']);
echo "路徑位置:".'<a href="file/'.$_FILES['file']['name'].'">file/'.$_FILES['file']['name'].'</a>';
echo "<br />";
echo "類型:".$_FILES['file']['type']."<br />大小:".$_FILES['file']['size']."<br />";
?>
</body>
</html>