PHP图片上传不能将实际文件复制到目标文件夹


php image upload cant copy the actual file to the destination folder

我有一个问题,当试图上传图像到我的mysql数据库有3个字段:id(自动增量),用户名和图像位置。代码只是将图像位置插入到数据库中,而不是将实际图像复制到"profile_pics"目录中。请协助。

这是我的代码:

<?php
$connection=mysql_connect("localhost", "root", "");
$choose_db=mysql_select_db("ninjacity", $connection) or die (mysql_error());
if ($_SESSION['user'] && $_POST['submit'])
{
    function check() // to check if the pic already exists
    {
        $username=$_SESSION['user'];
        $choose_db;
        $sql_check="SELECT * FROM profile_pics WHERE username='$username'";
        $res_check=mysql_query($sql_check) or die (mysql_error());
        return mysql_num_rows($res_check);
    }
    $name=$_FILES['image']['name'];
    $tmp_name=$_FILES['image']['tmp_name'];

        $check=check();
        if ($check==1)
        {
            echo "You already have a profile pic. IF you wish to change it, please use the 'Edit my Profile' section";
        }
        else
        {
            $name;
            $tmp_name;
            $username=$_SESSION['user'];
            $location="profile_pics/$name";
            move_uploaded_file($tmp_name, "profile_pics/".$name);
            $choose_db;
            $sql="INSERT INTO profile_pics VALUES ('$_POST[id]', '$username', '$location')";
            $res=mysql_query($sql) or die (mysql_error());
            print "Image successfully uploaded";
        }
}
else
{
    echo "Please fill all fields";
}

?>

是否检查了profile_pics目录的权限?应该是777。

或者与move_uploaded_file中使用的路径(目录的目标路径)相关的问题。