How to test if a user has uploaded a file ?
- by Tristan
Hello,
on a page, i have :
if (!empty($_FILES['logo']['name'])) {
$dossier = 'upload/';
$fichier = basename($_FILES['logo']['name']);
$taille_maxi = 100000;
$taille = filesize($_FILES['logo']['tmp_name']);
$extensions = array('.png', '.jpg', '.jpeg');
$extension = strrchr($_FILES['logo']['name'], '.');
//Début des vérifications de sécurité...
if(!in_array($extension, $extensions))
{
$erreur = 'ERROR you must upload the right type';
}
if($taille>$taille_maxi)
{
$erreur = 'too heavy';
}
if(!empty($erreur))
{
.......................
}
The problem is, if the users wants to edit information WITHOUT uploading a LOGO, it raises an error : 'error you must upload the right type'
So, if a user didn't put anything in the inputbox in order to upload it, i don't want to enter in these conditions test.
i tested :
if (!empty($_FILES['logo']['name']) and if (isset($_FILES['logo']['name'])
but both doesn't seems to work.
Any ideas?
thanks.