How can this code be changed from creating a random string file name to
simply adding user_id to the name of the file name that is chosen, for example adding user_id+image.png would ultimately be user_idimage.png?
Thanks for any help.
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = strtolower( end($temp) );
if ( $_FILES["file"]["size"] < 2000000 && in_array($extension, $allowedExts)){
if($_FILES["file"]["error"]!= 0){
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}else{
$length = 20;
$randomString = substr(str_shuffle(md5(time())),0,$length);
$newfilename = $randomString . "." . $extension;
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
$file_location = '<a href="http://www.---.com/upload/' . $newfilename . '">http://www.---.com/upload/' . $newfilename . '</a>';
}
}else{
echo "Invalid upload file";
}