Array ( [0] => Oops. Your photo's size is 1.76 mb. Max allowed is 1 mb. )
Array ( [0] => Sorry, only jpeg/jpg, gif, and png extensions allowed. )
这些错误会在我们的旧服务器上抛出......但不会在我们的新服务器上抛出。它只是将用户返回到上传页面。它仍然可以正常运作......只是没有 错误消息。
任何想法可能是什么原因?
Old server:
upload_max_filesize set to 20M
post_max_size set to 20M
New server:
upload_max_filesize set to 2M
post_max_size set to 2M
测试文件大小:1.76 mb
以下是代码:
<?php if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$file_name=strtolower($file_name);
$file_name = str_replace(' ', '', $file_name);
$random_digit=rand(0000000,9999999);
$file_name=$random_digit.$file_name;
$extensions = array("jpeg","jpg","gif","png");
if(in_array($file_ext,$extensions )=== false){
$errors[]= "Sorry, only jpeg/jpg, gif, and png extensions allowed.";
}
else if ($file_size > 1097152){
$file_size=$file_size/1048576;
$errors[]= "Oops. Your photo's size is ".round($file_size,2)." mb. Max allowed is 1 mb.";
}
else if (file_exists("images/" . $file_name))
{
echo $file_name . " already exists. ";
}
if(empty($errors)==true){
if(move_uploaded_file($file_tmp,"images/".$file_name)){
mysqli_query($connect,"UPDATE users SET image='$file_name'
WHERE id LIKE '$id'");
mysqli_close();
include "php_image_magician/1.1_resize_basic.php";
}
}else{
print_r($errors);
}
}
if(empty($errors)==true){
echo "Success";
}
?>