title: php write tmp file to image
body: <p>I am trying to covert the uploaded binary file into JPG format.</p>
  
  <p>Here are the code.</p>
  
  <pre><code> $uploaddir = '../images/upload_photo/';
  
   imagejpeg(imagecreatefromstring(file_get_contents($_FILES["file"]["tmp_name"])), "tmp.jpg");
   move_uploaded_file("tmp.jpg", $uploaddir.$filename);
  </code></pre>
  
  <p>However, the output file is empty and fail to display any image, How can I fix this problem?</p>