1
我嘗試了很多,但還不能得到解決,請幫助我,因爲我無法上傳我的文件代碼如下所示:無法上傳文件在PHP
<?php
$allowedExts = array("PSD", "JPG", "JPEG", "GIF", "PNG", "AI", "ZIP", "RAR", "PDF", "DOC", "DOCX", "XLS", "XLSX", "PPT");
$extension = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
if (($_FILES["file"]["size"] < 200000) && array_search($extension, $allowedExts)!==false) {
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"]/1024) . " Kb<br/>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("uploaded_files/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"common/uploaded_files" . $_FILES["file"]["name"]);
echo "Stored in: " . "common/uploaded_files" . $_FILES["file"]["name"];
}
}
} else {
echo "Invalid file";
}
?>
下面
是我的PHP的形式代碼:
<input type ="file" name= "file" id ="file"/>
您的表單是否具有'
是的,它是在我的形式dere但仍然我得到錯誤無效的文件 –
這意味着如果條件不起作用,你是上傳一個大文件'> 200000' – Nehal