Need image validation in php
<p>i'm trying to put validations on image upload code. but not properly working. so please give easy validation code for image upload in following.. image extension validation &amp; image size limit validation. i'm putting on my upload code as..</p>

<pre><code>&lt;form action="&lt;?php $_SERVER['PHP_SELF'];?&gt;" method="post" enctype="multipart/form-data" name="addroom"&gt;
Category Name:&lt;input type="text" class="textfield" id="category_name" name="category_name" value=""/&gt;&lt;br&gt;
Description:&lt;input type="text" class="textfield" id="description" name="description" value=""/&gt;&lt;br&gt;
Category Image:&lt;input type="file" class="textfield" id="image" name="image" value=""/&gt;&lt;br&gt;
&lt;input type="submit" id="Submit" name="Submit" value="Add" /&gt;
&lt;/form&gt;

&lt;?php
include('config.php');

if (!isset($_FILES['image']['tmp_name'])) 
{
echo "";
}
else
{
$file=$_FILES['image']['tmp_name'];
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name= addslashes($_FILES['image']['name']);

move_uploaded_file($_FILES["image"]["tmp_name"],"photos/" . $_FILES["image"]["name"]);

$location="photos/" . $_FILES["image"]["name"];
$category_name=$_POST['category_name'];
$description=$_POST['description'];

$save=mysql_query("INSERT INTO category (category_name, description, category_image) VALUES ('$category_name', '$description', '$location')");
header("location: category_insert.php");
exit();                 
}
?&gt;
</code></pre>
