# \[php\] if elses help

**URL:** <https://forum.kirupa.com/t/php-if-elses-help/123305>\
**Category:** Uncategorized\
**Created:** [September 22, 2004, 12:01pm UTC](https://forum.kirupa.com/t/php-if-elses-help/123305 "2004-09-22T12:01:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alapimba](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@alapimba](https://forum.kirupa.com/u/alapimba)\
**Post date:** [September 22, 2004, 12:01pm UTC](https://forum.kirupa.com/t/php-if-elses-help/123305/1 "2004-09-22T12:01:01Z")

</div>

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 😊

Thanks once again
