I am trying to upload an image to my server. I have a form that POSTS the filename. Then the page reloads and tries to upload that filename. I CHMOD' the directory of the files to read and write. I'm on a UNIX server. For some reason everytime I try to upload an image it won't work. here is the code:
if ($upload == "TRUE" || $upload == "EDIT") {
$file = $_POST['file'];
// If you havent already bought an avatar then
if (isset($file) && trim($file) != "") {
$clientpic = trim("graphics/avatars/".$_SESSION['name'].".jpg");
if(file_exists("$clientpic")) unlink("$clientpic");
if (copy($file, $clientpic)) {
$tokens = $tokens - 5;
$sql = "UPDATE members SET tokens = '".$tokens."' where username = '".$_SESSION['name']."'"; mysql_db_query($database, $sql, $Link);
$sql = "UPDATE members SET avatar = '".$clientpic."' where username = '".$_SESSION['name']."'"; mysql_db_query($database, $sql, $Link);
$showtext = "<br><br><b><center>You just purchased avatar privelages!</center></B><br>You can change your avatar at anytime by clicking on the avatar link on the left.<br>";
} else {
$showtext = "<br><br><b><center><font color='#FF0000'>Your image could not be uploaded!</font></center></B>";
$UserPic = "";
}
}
}
I haven't incorporated the resizing, but I want it to be able to scale the image down to fit in a 75x75 box.