[php] if elses help

hello
my question is pretty simple.
i have and upload form with this to check the file format:

$types_array = array(“image/gif”,“image/pjpeg”,“image/x-png”);
if (!in_array($_FILES[‘userfile’][‘type’], $types_array)) {
echo "file type not allowed
";
exit;
}

and then i have this:
if ($_FILES[‘userfile’][‘name’] == “”) {
$dir = $_POST[‘fotohidden’];
} else {
$dir = $uploadfile;
}

how can i put that file check thing inside my else… i mean… i only want it to check the file type when the file name is not empty…

i guess the code is all there it’s just a question of if’s and elses and i don’t know how to write them :blush:

Thanks once again


$types_array = array("image/gif","image/pjpeg","image/x-png");

if ($_FILES['userfile']['name'] == "") {
  $dir = $_POST['fotohidden'];
} else {
  if (!in_array($_FILES['userfile']['type'], $types_array)) {
    echo "file type not allowed
";
    exit;
  }
  $dir = $uploadfile;
}

Hope that helps.

thx :wink: