I have this function to check if the file is an image or not, but it always returning false
function upload_file($file) {
if($file['type'] != "image/jpeg" || $file['type'] != "image/gif") {
$errors[] = "Please upload a photograph with extenstion of JPEG, JPG, GIF or BMP.";
return false;
}
}
so can anyone tell me where i gone wrong here!
Thanks in advance.
You needs to use
&&:By using
||you’re causing it to always be false since no image can be both a jpeg and a gif