Hi iam trying to upload an image into database but it is inserting the tmp_name in the database.Can anyone help me this .
Here is my code
<?php
$connection = mysql_connect("localhost", "root", "") or die(mysql_error());
$db = mysql_select_db("accountant", $connection);
$title=$_POST['blog_title'];
$description=$_POST['blog_description'];
$name=$_FILES["image"]["tmp_name"];
$type=$_FILES["image"]["type"];
$size=$_FILES["image"]["size"];
$temp=$_FILES["image"]["tmp_name"];
$error=$_FILES["image"]["error"];
if($error>0)
die("error while uploading");
else
{
if($type == "image/png" || $type == "image/jpeg" ||$type == "image/jpg" || $type == "image/svg" || $size >2000000)
{
move_uploaded_file($temp,"upload/".$name);
$sql=mysql_query("INSERT INTO blogs(image,blog_title,blog_description)values('$name','$title','$description')");
echo "upload complete";
}
else
{
die("Format not allowed or file size too big!");
}
}
Iam trying to insert an image getting errors as
Warning: move_uploaded_file(upload/C:\xampp\tmp\php1908.tmp): failed to open stream: Invalid argument in C:\xampp\htdocs\accounting\admin\blogs.php on line 21
Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php1908.tmp' to 'upload/C:\xampp\tmp\php1908.tmp'
In database it is inserting as C:xampp mpphp1908.tmp