I am currently using this code so users can upload images to my site
$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.jpeg','.JPG','.PNG','.BIF','.GIF','.JPEG'); // These will be the types of file that will pass the validation.
$max_filesize = 524288; // filesize in BYTES (currently 0.5MB).
$uploadpath = "/home/path/to/file/files/avatars/$_SESSION[user]";
$posted9 = hash('md5',$_SESSION["user"]).$ext; /* not for security mind you. */
// Upload the file to your specified path.
$f = file_put_contents(
$upload_path . $posted9,
file_get_contents('php://input')
);
if($f)
$m="Avatar updated<br/>"; // It worked.
else
$m="There was an error during the file upload. Please try again."; // It failed :(.
However, when the images are rezised to fit inside the comments on my website, they become distorted and lose their quality.
How using PHP can I resize the images so that the quality is maintained?