Forum Moderators: coopster

Message Too Old, No Replies

image upload script gone wrong!

what did I do?

         

NogginAnimations

5:31 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



well, I got my image uploader working a while ago, but I changed it when users had their own directories, and now it doesn't upload.
The SQL and everything is fine, it's just the files won't upload at all.
The directories are in the right place as far as I know...


<?
$upltous = $_POST['usernm'];
include 'database.php';
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$ext = findexts ($_FILES['path']['name']) ;
$ran = $upltous."_".rand() ;
$ran2 = $ran.".";
$target_pathe = "/".$upltous."/";
$target_path1 = $target_pathe . $ran2.$ext;
if(move_uploaded_file($_FILES['path']['tmp_name'], $target_path1)) {
echo "file.. success.. redirecting";
} else{
echo "file.. error.. redirecting";
}

$sql="UPDATE users SET avatar='$target_path1' WHERE username='$upltous'";
$result=mysql_query($sql);
if($result){
echo 'SQL.. success.. redirecting';
}
else {
echo 'SQL.. error.. redirecting';
}
?>

NogginAnimations

5:34 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



PS: PLEASE DON'T WORRY I FIXED THE PROBLEM
I simply needed to decapitalize the variable $upltous by using
"$upltous = strtolower($upltous);"

Please close or trash the topic

eelixduppy

11:00 pm on Jan 13, 2008 (gmt 0)



Glad you found your solution and Welcome to WebmasterWorld! :)