Possible Duplicate:
PHP resize and upload an image
I have a website where user's can upload photos. Now, I am starting to realize that some of the photos need to be re-sized and converted. I know how to upload and move photos, but how do I re-size them if they are too big and convert them to JPEG's if they aren't?
Here is my PHP:
if ($_FILES['media']['size'] != 0) {
$target= UPLOADPATH . $media;
move_uploaded_file($_FILES['media']['tmp_name'], $target);
$query= "INSERT INTO posts (user_id, story, media, date, view, type)
VALUES ('$user_id', '$story', '$media', now(), '$view', '1')";
mysqli_query($connect, $query) or die('error with query 2');
}