Resizing photos on upload
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php">How to prevent SQL injection in PHP?</a><br>
  <a href="http://stackoverflow.com/questions/6608586/php-resize-and-upload-an-image">PHP resize and upload an image</a>  </p>
</blockquote>



<p>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?</p>

<p>Here is my PHP:</p>

<pre><code>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');
}
</code></pre>
