Copy()函数无法正常工作。 PHP

时间:2016-10-22 22:25:35

标签: php copy mkdir

我一直在努力尝试,但我似乎无法让它发挥作用。我在这个网站上看到了类似的解决方案,但它对我不起作用。

我正在尝试将默认个人资料图片传递到用户的文件夹中。该文件夹是为用户创建的,但它仍为空。

有任何建议/想法吗?

PHP:

$profile_pic = $row['avatar'];  
        //$g = gender   
        if($g == "f"){
                $profile_pic = "default_woman.jpg";
            } else{
                $profile_pic = "default_man.jpg";
            }
            '<img src="img/'.$profile_pic.'" >';
// Add user info into the database table
        $sql = "INSERT INTO users (firstName, lastName, username, email, password, gender, country, avatar, ip, signup, lastlogin, notescheck)       
                VALUES('$fn','$ln','$u','$e','$p_hash','$g','$c','$profile_pic','$ip',now(),now(),now())";
        $query = mysqli_query($db, $sql); 
        $uid = mysqli_insert_id($db);
        // Create directory(folder) to hold each user's files(pics, MP3s, etc.)
        if (!file_exists("user/$u")) {
            mkdir("user/$u", 0755);
        }
        copy($profile_pic,"user/$u/$profile_pic");

0 个答案:

没有答案