title: How to pass is_uploaded_file check in php?
body: <p>I am uploading file to tmp folder from external file using php code(not from user post request), then fill $_FILES with information for that file and pass it to code that uses $_FILES variable. 
  But inside that code, it uses move_uploaded_file, that has is_uploaded_file check. File uploaded manually by code(not by user form posted) fails this check because it was not uploaded using POST. Can I make it pass that check?</p>
  
  <p>Code that fails:</p>
  
  <pre><code>//$url contains url of image from another site
  function upload_from_url($url)
  {
      global $modx;
      // we load temporary file to /tmp and then add it to $_FILES
      $img = '/tmp/'.uniqid("", true); // no extension here since we can't trust it
      $res = file_put_contents($img, file_get_contents($url)); // UPLOAD is made here, it works
      $mimeType = mime_content_type($img);
      $allowedMimeTypes = ["image/jpeg","image/gif","image/png"];
      if (!in_array($mimeType, $allowedMimeTypes))
      {
          logError("!!!ATTENTION!!! got file $img with forbidden mime type $mimeType");
          throw new RuntimeException("Forbidden file mime type!"); 
          die; // just to be sure; shouldn't get here
      }
      $_FILES['file']['name'] = uniqid("img", true)."."
          .(explode("/", $mimeType)[1]); // get jpg part of image/jpg
      $_FILES['file']['type'] = $mimeType;
      $_FILES['file']['tmp_name'] = $img;
      $_FILES['file']['error'] = 0; // = UPLOAD_ERR_OK
      $_FILES['file']['size'] = filesize($img);
      $response = $modx-&gt; runProcessor('browser/file/upload', ['path' =&gt; 'assets/images']); // &lt;= here it fails
  }
  </code></pre>
  
  <p>Inside <code>$modx-&gt; runProcessor('browser/file/upload'...</code>  code, there is part that fails:</p>
  
  <pre><code>    if (!move_uploaded_file($file['tmp_name'],$newPath)) {
          $this-&gt;addError('path',$this-&gt;xpdo-&gt;lexicon('file_err_upload'));
          continue;
      }
  </code></pre>
  
  <p>It gets $file from $files from $_FILES variable, and I don't want to modify framework code to workaround it.</p>