The code is not able to insert an image into the database because it does not go past the if statement. When i run the application, i always get "Please Insert a valid image". I don't get any errors in the code. Please your help will be appreciated.
<form action="uploadtest.php" method="POST" ectype="multipath/form-data">
<label>Picture:</label><input type="file" name="image">
<input type="submit" name="submit" value="Add Record">
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("testlab");
//file properties
if(empty($_FILES) || !isset($_FILES['image']))
{
echo "Please Insert a valid image";
}//end of if statement
else
{
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if($image_size==FALSE)
echo "This is not an image.";
else
{
mysql_query("INSERT into testimage VALUES('','$image_name','$image'");
echo "Image Successfully inserted into the Database";
}
}//end of else statement
?>