io faccio così...
Codice PHP:
$path = "tuacartelladiupload"
$size = "100000"; // grandezza in byte...
//tipi di immagini
$tipo1 = "image/pjpeg"; //Jpeg tipo 1
$tipo2 = "image/jpeg"; //Jpeg tipo2
$tipo3 = "image/gif"; //Gif etc... puoi mettere quelli che vuoi..
if ($_FILES['img1']['size'] > $size)
{
$log= "Il file è troppo grande";
}else{
if (($_FILES['img1']['type'] == $tipo1) or ($_FILES['img1']['type'] == $tipo2) or ($_FILES['img1']['type'] == $tipo3))
{
// qui uploadi il tuo file...
$uploadfile = $path."/". $_FILES['img1']['name'];
if (move_uploaded_file($_FILES['img1']['tmp_name'], $uploadfile))
{
$log= "file uploaded succesfully";
}
else {$log= "file not uploaded";}
}
}