title: Using fopen() to write file into subdirectory
body: <p>I already looked at <a href="https://stackoverflow.com/questions/9837337/trying-to-write-a-file-to-a-different-directory-using-fopen">this</a> StackOverflow question and it didn't help (similarly titled).</p>
  
  <p>I'm passing an image in from my Android application.  If I type</p>
  
  <pre><code>$file = fopen('test.jpg', 'wb');
  </code></pre>
  
  <p>It works correctly and the image uploads; however, I want to allow for multiple uploads from android phones, so I want to randomize the name of the .jpg file so that I can save each new upload as a different name.  I was trying this below:</p>
  
  <pre><code>$destination =  time() + rand(1, 1000) . ".jpg";
  $url_destination = "/project_images/" . $destination;
  
  $file = fopen($url_destination, 'wb');
  fwrite($file, $binary);
  fclose($file);
  </code></pre>
  
  <p>It doesn't write the file to the server, however.  I tried different variations of the URL there - with 'project_images/', '/project_images/', even trying the full URL (which the aforementioned StackOverflow post corrected me on), and I still can't get it to write.</p>
  
  <p>The permissions of the project_images folder are set to allow files to be written to it.  Any ideas?</p>