am working on a website where adverts will be placed. the advert can be in any of the following formats JPG, JPEG, GIF, PNG or SWF(flash). I used the below code to check for the format of the file, it works when uploading file in JPG, JPEG, GIF, PNG formats but when uploading SWF telling me that the file for mar is not supported.
Code: Select all
$image_type = strstr(($_FILES["file"]["name"]), '.');
$file_type = (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/swf"));
$file_size = 5242880;
if($_FILES["file"]["name"] == "")
echo "<span class='style3'>You must upoad your Banner.</span><br>";
elseif (($_FILES["file"]["name"] !="") && $image_type != $file_type)
echo "<span class='style3'>The Picture format is not supported, upload a supported format.</span><br>";