Good,
I have a problem with my code, I have an image upload and I have defined that the size should be less than 2MB and 280 x 280 px.
What happens is that when an image is uploaded $ _FILES ['avatar'] ['tmp_name'] ceases to exist, but only when the image is greater than 2 MB and does not output this error. And if it is less than 2MB but over 280x280 px, it gives the output of this correct error.
And I'm not using the input MAX_UPLOAD_SIZE I think that's what it's called. Here's the input:
<form enctype="multipart/form-data" action="perfil.php" method="POST" role="form">
<input type="file" name="avatar" accept="image/x-png, image/gif, image/jpeg" onchange="av()" data-placement="bottom" data-toggle="tooltip" title="Limite 2MB"></div>
Here's the PHP code,
define('MB', 1048576);
if(isset($_POST['avatar'])){
$img = true;
$nome = $_SESSION["tipo"].$_SESSION["id"];
$uploaddir = "C:/Program Files (x86)/VertrigoServ/www/teste/avatar/";
$uploadfile = $uploaddir . basename($_FILES['avatar']['name']);
$imageFileType = pathinfo($uploadfile,PATHINFO_EXTENSION);
$upFinal = $uploaddir . $nome . "." . $imageFileType;
$uploadOk = 1;
if(filesize($_FILES["avatar"]["size"]) > 2*MB) {
$size = true;
$uploadOk = 0;
}
if(!empty($_FILES['avatar']['tmp_name'])){
$imgS = getimagesize($_FILES['avatar']['tmp_name']);
$imgW = $imgS[0];
$imgH = $imgS[1];
if($imgW > 280 || $imgH > 280){
$pixels = true;
$uploadOk = 0;
}
}
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ){
$type = true;
$uploadOk = 0;
}
if ($uploadOk == 1){
if(move_uploaded_file($_FILES["avatar"]["tmp_name"], $upFinal)) {
$up = true;
$avatar= "/empregos/docs/". $nome . "." . $imageFileType;
mysqli_query($mysqli,"UPDATE candidatos SET avatar= '$avatar' WHERE id = '$id'");
header("Location:login.php?update=".$_SESSION['tipo']."");
}
}
}