我在將move_upload_file()函數引用到另一個頁面時遇到問題。它工作沒有任何錯誤。但問題是選定的文件沒有被傳送到指定的目錄。move_uploaded_file()函數在引用另一個頁面時不起作用
我不知道是什麼問題,並感謝任何形式的幫助或建議。
下面是代碼:
PAGE 1(其中輸入被完成):
<form name='NewsForm' method='post' action='conf_news.php' enctype='multipart/form-data' >
<input type="file" name="file" id="file" value='' >
<input type='submit' name='AddNews' value='POST' >
</form>
它帶來代碼到另一頁 「conf_news.php」 其中i引用所存儲的文件的部分: PAGE 2:
$PicMessage = "";
$PicName = addslashes($_FILES["file"]["name"]);
$PicType = addslashes($_FILES['file']['type']);
$PicSize = addslashes($_FILES['file']['size']);
$PicError = addslashes($_FILES["file"]["error"]);
$PicTempName = addslashes($_FILES["file"]["tmp_name"]);
$allowedExt = array('jpeg', 'jpg', 'gif', 'png');
$a = explode(".", $PicName);
$extension = end($a); unset($a);
if((($PicType == "image/gif")
|| ($PicType == "image/png")
|| ($PicType == "image/jpeg")
|| ($PicType == "image/jpg")
&& ($PicSize > 100)
&& in_array($extentions, $allowedExt))){
if($PicError > 0){
$PicMessage = "Error Type: ". $PicError. "<br />";
}
else{
echo "Upload: ". $PicName. "<br />";
echo "Type: ". $PicType. "<br />";
echo "Size: ". ($PicSize/1024). " Kb<br />";
echo "Stored in: ". $PicTempName;
if(file_exists("../photos/". $PicName)){
$PicMessage = "File Already Exists";
}
else{
move_uploaded_file($PicTempName, "../photos/". $PicName);
$PicMessage = "Stored in: ". "../photos/". $PicName;
}
}
}
else{
$PicMessage = "Invalid File Type";
}
圖片消息顯示該文件被轉移,但ptohos文件夾爲空。我真的無法思考什麼是錯的。
很多感謝所有誰都會花時間對我的幫助。
檢查move_uploaded_file()返回的內容 – 2012-12-26 03:00:14