This code works properly in my localhost. I am using xampp 1.7.3. but when I put it in the live server it shows Possible file upload attack!
. \'upload/\' is the fol
Try this code
$fltype=$_FILES['userfile']['type'];
echo $fltype."
";
/*if($_FILES['userfile']['type'] != "image/gif") {
echo "Sorry, we only allow uploading GIF images";
exit;
}*/
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$imgname=basename($_FILES['userfile']['name']);
$desc=$_POST["desc"];
echo "
".$imgname."
";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "File uploading failed.\n";
}
$con=mysql_connect("localhost","root","");
$select=mysql_select_db("n1",$con);
$sql="insert into tblimage (imagename,description) values('$imgname','$desc')";
echo "
".$sql;
$rs=mysql_query($sql);
if($rs)
{
echo "
Record inserted in table.
";
}
else
{
echo "
Error in table insersion.
";
}
echo "
uploaded image is::::
";
echo "";
?>