任何人都可以用我的代碼推斷出什麼可能是問題嗎?當我試圖上傳超過8 MB的PDF文件時,這是我收到的消息:在php上使用文件上傳得到錯誤
出錯了[沒有文件上傳]文件已存在於服務器上。
這是我輸入了代碼:
<?php
$name = $_FILES['file']['name'];
$storefile_loc = "uploads/";
$storefile_path = $storefile_loc.basename($name);
//$get_ext=explode(".",$_FILES['file']['name']); //separates file name from extension
//$ext=end($get_ext); //gets the extension from above explosion
$txtFileType = pathinfo($storefile_path,PATHINFO_EXTENSION);
$goodext = array("txt","doc","odt","docx"); //array of extensions for app
//Check if files are .txt (.doc, and .pdf functionality to be added)
if (isset($_POST["submit"])){ //checks if form has been submitted
//$check=mime_content_type($name);
if (($_FILES['file']['type'] == "text/plain")
||($_FILES['file']['type'] == "application/pdf")
||($_FILES['file']['type'] == "application/vnd.oasis.opendocument.text")
||($_FILES['file']['type'] == "application/msword")
||($_FILES['file']['type'] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
&&(in_array($txtFileType,$goodext))){
echo "Uploading File...";
}
else {
echo "You can only upload a txt/doc/docx/pdf/odt file.";
}
}
else {
echo "Something went wrong [No file uploaded]";
}
//Check if file already exists. Probably won't need this
if (file_exists($storefile_path)){ //this instead of $name because it's checking server
echo "File already on server.";
}
//Check file size
if ($_FILES['file']['size'] > 2000000){
echo "File is too large.";
}
//Way to upload permanently. Probably won't need this
/*
if (move_uploaded_file($_FILES['file']['tmp_name'], $storefile_path)){
echo "The file '".basename($_FILES['file']['name'])."' has been uploaded.";
}
else {
echo "Something went wrong when uploading your file.";
}
*/
?>
我也得上線2的36是我的代碼問題通知的錯誤?還是與Apache?
首先檢查'upload_max_filesize'和'post_max_size'大於'8MB' –
什麼錯誤和什麼是在這些行上,'我也在第2行和第36行發現了錯誤。是否我的代碼存在問題?' – ArtisticPhoenix