2012-11-11 108 views

回答

1

您將需要使用一個簡單的文件形式上傳

HTML

<form action="upload_file.php" method="post" enctype="multipart/form-data"> 
<input type="file" name="file" id="file" /> 
<input type="submit" name="submit" value="Submit" /> 
</form> 

PHP(upload_file.php)

if (file_exists("upload/" . $_FILES["file"]["name"])) { 
echo $_FILES["file"]["name"] . " already exists. "; 
} else { 
move_uploaded_file($_FILES["file"]["tmp_name"], 
"upload/" . $_FILES["file"]["name"]); 
echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; 
} 
相關問題