I have a upload script where users can upload images. I have a condition to verify if the file size is greater than 2 megabytes. but it is returning false for images of less than 2 megabytes.
Any suggestions?
$image = $_FILES['image'] ?? '';
if (!has_max_file_size($image)) {
$errors['images'] = 'File too large. File must be less than 2 megabytes. ';
}
function has_max_file_size($file)
{
return $file['size'] > 2097152; // 2 MB
}
Aucun commentaire:
Enregistrer un commentaire