title: PHP move_uploaded_file to directory and create file
body: <p>I have a script that uploads a file and then moves it to a directory. However the script does not know the name of the file its creating because it hasn't created it yet and cannot find the file to update.</p>
  
  <p>So either one requires a way to make the file first or there is another way of doing this. The code.</p>
  
  <pre><code>&lt;?php
  
  $filename = '/home/divethe1/public_html/update/z-images/admin/upload/test/';
  
  if ($_FILES['thumbfile']['error'] === UPLOAD_ERR_OK) {
      $info = getimagesize($_FILES['thumbfile']['tmp_name']);
      if (($info[2] !== IMG_GIF) &amp;&amp; ($info[2] !== IMG_JPEG)) {
         die("not a gif/jpg");
      }
      if (filesize($_FILES['thumbfile']['tmp_name']) &gt; 100000) {
         die("larger than 100000");
      }
      move_uploaded_file($_FILES['thumbfile']['tmp_name'], $filename . $_FILES['thumbfile']['name']);
  
        echo '&lt;script type="text/javascript"&gt;
  parent.document.getElementById("thumbprogress").innerHTML = "Archiving"&lt;/script&gt;Archiving';
  
    }
  else
    {
    echo '&lt;script type="text/javascript"&gt;
  parent.document.getElementById("thumbprogress").innerHTML = "Invalid File Format"&lt;/script&gt;Invalid File Format';
    }
  ?&gt;
  </code></pre>
  
  <p>Any ideas?</p>