title: Using imagejpeg() function to save image file
body: <p>I am trying to upload the picture into two different directories and I would like to use the <code>imagejpeg()</code> function to put the picture in one of the directories. The two directories are called <code>uploads</code> and <code>resized</code>. </p>
  
  <p>Here is my code to accomplish this:</p>
  
  <pre><code>$tmp_name = $_FILES["fileToUpload"]["tmp_name"];
  if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
      imagejpeg($tmp_name,"resized/newimage.jpg");
  
      echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
  } 
  </code></pre>
  
  <p>However, I keep getting the error <code>imagejpeg() expects parameter 1 to be resource, string given in /home/sites/aejhyun.com/public_html/Syrian Project/upload.php on line 41</code>. I also did some research by looking here <a href="http://php.net/manual/en/function.imagejpeg.php" rel="nofollow">http://php.net/manual/en/function.imagejpeg.php</a> and <a href="http://php.net/manual/en/function.move-uploaded-file.php" rel="nofollow">http://php.net/manual/en/function.move-uploaded-file.php</a>. However, I could not figure this problem out. Could anybody help?</p>