if ($image != '')
{
$filedir = "/home/students/public_html/userphotos/";
$userfile_name = $_FILES['image']['name'];
$userfile_tmp = $_FILES['image']['tmp_name'];
$userfile_size = $_FILES['image']['size'];
$userfile_type = $_FILES['image']['type'];
$imagesize1 = getimagesize($userfile_tmp);
if ($imagesize1[2] == '1'){
$ext = 'gif';}
if ($imagesize1[2] == '2'){
$ext = 'jpg';}
if ($imagesize1[2] == '3'){
$ext = 'png';}
$newfilename = $HTTP_SESSION_VARS['username'] . "_". md5(microtime() . $HTTP_SERVER_VARS['REMOTE_ADDR']) . '.' . $ext;
$newfile = rename("$userfile_tmp/$userfile_name", "$filedir$newfilename");
if (!$imagesize[2] == "1" || !$imagesize[2] == "2" || !$imagesize[2] == "3")
{
$sqlpath = "http://www.StudentsView.com/$newfilename";
$sqlimage = "<img src=\"$sqlpath\" border=\"0\" height=\"$imagesize[1]\" width=\"$imagesize[0]\">";
$sql = mysql_query("UPDATE sv_users SET user_photo = '$sqlimage' WHERE user_id = '$id'");
}
else{
echo 'The image you chose to upload was not a valid type.<br>Only JPEG, GIF, and PNG are allowed.';
exit;
}
}
else{
echo 'There was a problem while trying to upload your image. <br> Please try again later date';
}
That is the code I use for my image handling. Am I doing it right? I am getting this error:
Warning: rename(/tmp/phpDe7YK2/atlien.jpg,/home/students/public_html/userphotos/ATLien_d5279a54d5bc53ed5fd609c13dbffb5b.jpg): Not a directory in /home/students/public_html/profile.php on line 257
Does anyone know what could be causing this? the directory I am trying to put it in to is chmod 777. Could it be that the directories it is trying to access are not from the home? Like is it looking for them from the folder the file is in? Someone please help me.