Page 1 of 1

how to check swf banner format, dimension and file size

Posted: Fri Nov 05, 2010 5:54 am
by adsegzy
Hello friends,

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>";
Please how can go about checking the file format, dimension adn size of a flash banner (swf)?

Re: how to check swf banner format, dimension and file size

Posted: Fri Nov 05, 2010 6:44 am
by s.dot
Use getimagesize() to check for this kind of stuff. It is more secure than checking the mime type since it analyzes the files contents (plus, it will determine the mime type as well).

It will give you all of the info you need to know about the uploaded file.