I'm trying to upload image to mysql table. When image selected it's working fine. But without selecting image it's display error message. How can i fix it?
Warning: file_get_contents(): Filename cannot be empty in C:\wamp\www\firstdialnew\firstdial\adhandler.php on line 23
$stype=$_POST['stype'];
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
if($stype="")
{
echo "Please fill all the details";
}else{
$sql=mysql_query("INSERT INTO ads
(sid,stype,image,image_name)
VALUES(NULL,'$stype','$image','$image_name')");
echo "Details Successfully send";
}
ifcase is incorrect; use of deprecatedmysql_*functions; use of$_FILES'stmp_name; also, you didn't move your file from temp folder to final path.