0

Im creating a social network site and i was able to create a user folder each time a new user signs up but my problem is copying a default image from a folder to that user folder how can i do that? I've searched the web on solutions like using Copy function in php but itsn't working
You can check my code and i would be glad if anyone could help:

<?php

$link= mysqli_connect("localhost","root","","new1");

if($link === false)
{
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

$firstname = $_POST["firstname"];

$lastname = $_POST["lastname"];

$username= $_POST["username"];

$email = $_POST["Email"];

$password= $_POST["Password"];

$country= $_POST["Country"];

$gender= $_POST["Gender"];

$birthday= $_POST["birthday"];

$profilepicture= "default.gif";

$sql = "INSERT INTO 360tery (firstname, lastname, username,Email,Password,Country,Gender,birthday,Profilepicture) VALUES ('$firstname','$lastname','$username','$email','$password','$country','$gender','$birthday','$profilepicture')";

$result = mysqli_query($link, $sql);

if ($result)
{
    session_start();
    $_SESSION['email']= $email; 
    echo "<script type='text/javascript'>alert('Successfully Registerd!'); window.location.href='../html/updatedtimeline.html';</script>";
    mkdir("../html/users/".$username,0777);

    $defaultimagepath='../photos/default.gif'; //This is the path to my default image
    $userfilepath="../html/users/".$username."/"; //the path to the users file i want to copy image to 
    copy($defaultimagepath,$userfilepath); //copy function

}else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

?>
2
Contributors
2
Replies
17
Views
9 Months
Discussion Span
Last Post by rubberman
0

So, the question is whether this user folder is a system directory, or something in the database? These are very different things. If a system directory for the user, then select the image from MySQL into PHP, and then simply write it as a file to the appropriate user directory.

0

Just remember the KISS (Keep It Short and Simple) for your code. Yours is too complex for such a simple operation. Minimize! Minimize! Minimize! :-)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.