Firstly, try comparing it to the $_FILES SuperGlobal, like so:
if($_FILES['file']['type'] != "image/gif") {
Secondly, your logic is wrong 😉 That if statement should be "ANDed", not "OR'd".
Read through it logically,
if the uploaded image is not equal to jpeg, OR the uploaded image is not equal to png, OR the uploaded image is not equal to gif, then die. But this will ALWAYS return true, because the uploaded image would have to be equal to all 3.
What you want is, if it's not equal to ANY of them, so you'd use an && :
foreach($_FILES as $v) {
if(($v['type'] != "image/gif") && ($v['type'] != "image/pjpeg") && ($v['type'] != "image/jpeg")) {
unlink($v['tmp_name']);
die("Must be an image");
} else {
if(!move_uploaded_file($v['tmp_name'], "/path/to/".$v['name'])) {
unlink($v['tmp_name']);
die("Could not copy file");
} else {
echo "Yay! ".$v['name']." was uploaded!";
}
}
}