title: PHP Upload File - right code but can't find the file/path
body: <p>First question for quite a while. Essentially, I've got some code that (1) works perfectly in the live environment, (2) used to work in my home OSX environment but (3) doesn't work now.</p>
  
  <p>The HTML:</p>
  
  <pre><code>&lt;form id="upload_form" action="php/upload_class_list.php" method="post" accept-charset="UTF-8" enctype="multipart/form-data" target="upload_target" &gt;
      &lt;label&gt;File:&lt;/label&gt;
      &lt;input name="myfile" type="file" size="35" /&gt;
      &lt;input id="upload_submit" type="submit" value="Upload" /&gt;
      &lt;iframe id="upload_target" name="upload_target" style="width:0;height:0;border:0px solid #fff;"&gt;&lt;/iframe&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The PHP file:</p>
  
  <pre><code>$destination_path = getcwd().DIRECTORY_SEPARATOR;
  
  $result = 0;
  
  $target_path = $destination_path . basename( $_FILES['myfile']['name']);
  
  if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {   
     ...
  }
  
  sleep(1);
  ?&gt;
  
  &lt;script language="javascript" type="text/javascript"&gt;top.upload_class_list(&lt;?php echo $result; ?&gt;);&lt;/script&gt;
  </code></pre>
  
  <p>The script fires at the end, but the PHP code doesn't enter the <code>if</code> (in the local development environment) and so <code>$result</code> remains at 0.</p>
  
  <p>It seems it's not picking up the <code>path</code> of the file to be uploaded; <code>$destination_path</code> points to the folder where the PHP file is located, and not where the file is found.</p>
  
  <p>I think my local environment may have stopped working when I changed to Mountain Lion and rebuilt the PHP setup. </p>
  
  <p>What is missing to stop the file being found?</p>
  
  <p>Let me emphasise: exactly the same code works fine in my live Hostmonster setup, so it's an environment problem, I guess :)</p>
  
  <p>Thanks.</p>