This is my code. Javascript is to show the fileupload box. PHP is to check if the file type is .gif It always gives an error. Any idea why this would happen. I checked the file name array and it seems to not exist. Javascript Code: if(document.getElementById('img_file').innerHTML == '') { document.getElementById('img_file').innerHTML = 'Browse To The Image File (.gif).<br/><input name="imgfilename" type="file" id="imgfilename" class="textbox" />'; } Code (markup): PHP code $fileext = pathinfo($_FILES['imgfilename']['name'], PATHINFO_EXTENSION); $fileext = strtolower($fileext); $allowedexts = array("gif"); if(in_array($fileext, $allowedexts)) { } else { $imgerror = 'Please choose a valid image file to upload! File type must be .gif'; $showfail = 1; } if($_FILES['imgfilename']['size'] > 20000) { $imgerror = 'Please choose a valid file to upload! Max size is 20KB'; $showfail = 1; } Code (markup):
Check that you have this in your form tag: enctype="multipart/form-data" If yes then what content do you get when you print_r($_FILES); within php on submit.
Also, change: if(in_array($fileext, $allowedexts)) { } else { $imgerror = 'Please choose a valid image file to upload! File type must be .gif'; $showfail = 1; } PHP: Too: if(!in_array($fileext, $allowedexts)) { $imgerror = 'Please choose a valid image file to upload! File type must be .gif'; $showfail = 1; } PHP: its cleaner.