以下是php上傳檔案的陽春版本,要分二個檔案,一個是.html檔,一個是.php檔
下圖是.html檔案

下圖是接收端的php的檔案
html原始碼:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>上傳檔案</title>
</head>
<body>
<form name="form1" method="post" enctype="multipart/form-data" action="9-2-1.php">
<p>姓名:
<input type="text" name="uname">
</p>
<p>選取要上傳的檔案...</p>
<p>
<input type="file" name="ufile">
</p>
<p>
<input type="submit" name="Submit" value="開始傳送">
<input name="Reset" type="reset" id="Reset" value="重設">
</p>
</form>
</body>
</html>
php原始碼:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>檔案上傳與接收</title>
</head>
<body>
<?php
//接收傳遞過來的使用者名稱
echo _POST["uname"]." 你好:<p>";
error_msg=_FILES["ufile"]["error"];
fname=_FILES["ufile"]["name"];
tmpname=_FILES["ufile"]["tmp_name"];
fsize=_FILES["ufile"]["size"];
ftype=_FILES["ufile"]["type"];
//判定檔案是否傳遞成功
if(error_msg){
echo "<font color=red>檔案沒有上傳成功!</font><p>";
echo "對應的錯誤碼是 -> ".error_msg;
}else{
//檔案上傳成功
echo "已經收到上傳的檔案,檔名是 -> ".fname."<br>";
echo "伺服器中暫存的位置和檔名 -> ".tmpname."<br>";
echo "上傳檔案的大小 -> ".fsize."<br>";
echo "上傳檔案的檔案類型 -> ".ftype."<br>";
echo "<hr>";
//將檔案另存到指定的位置
success=copy(tmpname,"newsql.txt");
if(success){
echo "檔案已經複製成功!<br>";
echo "新的路徑和檔名如下:<br>";
echo realpath("newsql.txt")."<p>";
//刪除暫存器中的檔案
unlink(tmpname);
}else{
echo "<font color=red>無法複製檔案!</font>";
}
}
?>
</body>
</html>
最後上傳到「C:\wamp\www\php\pro1\0009 0\newsql.txt」
當然副檔名不正確,這地方還要再判斷與修改一下。