how to check swf banner format, dimension and file size

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

how to check swf banner format, dimension and file size

Post 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)?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

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

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply