每次上传图片都说上传成功。当我检查我的 comp 上的临时文件夹时,是的,它是存储的,但是当涉及到数据库时,它不会存储我上传的任何图像。
<?php
if($_POST)
{
$con = mysqli_connect("localhost", "root", "", "pamphotos") or die('error in connection'.mysqli_connect_error());
$caption = $_POST['caption'];
$image_cont = 'c://uploads//';
$image_cont2= 'c://uploads//thmb//';
$filename = $_FILES["file"]["name"];
$src = $image_cont . $filename;
$thumb = $image_cont2. $filename;
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"c://uploads//" . $_FILES["file"]["name"]);
$q = "INSERT into photos(p_desc, p_src, p_thumbsrc) VALUES('$caption', '$src','$thumb')";
$stmt = mysqli_prepare($con, $q) or die('error in connection'.mysqli_connect_error());
if($stmt)
{
echo "File succesfully Uploaded.";
}
}
}
}