title: move_uploaded_file returns false, but $_FILES['uploadedfile']['error'] == 0
body: <p>I am using the POST method to upload a photo in my upload_photo.php file which uses uploader.php to process the image.  Uploader.php will resize the image and overwrite the old one.  It works fine locally, but not on the server.</p>
  
  <p><code>move_uploaded_file</code> returns false, but <code>$_FILES['uploadedfile']['error'] == 0</code> which does not make since to me.</p>
  
  <p>I have posted the entire uploader.php and a snippet from upload_photo.php which shows the form tag.</p>
  
  <pre><code>&lt;?php
  //This is uploader.php
  session_start();
  include ('dbconfig.php');
  include('SimpleImage.php');
  
  mysql_connect(HOST, USERNAME, PASSWORD);
  $conn = mysql_select_db(DB_NAME);
  
  $target_path = "uploads/";
  
  $target_path = $target_path . renameImage();
  
  $_SESSION['client_photo'] = $target_path;
  
  $query = "UPDATE client ";
  $query .= "SET personal_photo = ('$target_path') ";
  $query .= "WHERE client_id = ".$_SESSION['clientID'];
  $results = mysql_query($query) or die('Error msg: '.mysql_error().'&lt;br/&gt;
          sql: '.query.'&lt;br/&gt;');
  
  if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    $msg = "The file ".  $_SESSION['client_photo']. 
    " has been uploaded";
    chmod($target_path, "0666");
    $work = new ImgResizer($target_path); 
    $work -&gt; resize(600, $target_path); 
  } else{
    $msg = "There was an error uploading the file, please try again!";
    $msg .= $_FILES['uploadedfile']['error'];
  }
  header("Location: upload_photo.php?msg=$msg");
  
  function renameImage(){ 
    mysql_connect(HOST, USERNAME, PASSWORD);
    $conn = mysql_select_db(DB_NAME);
  
    $sql = "SELECT first_name, last_name, client_id
            FROM client
            WHERE client_id = ".$_SESSION['clientID'];
    $res = mysql_query($sql) or die('Error msg: '.mysql_error().'&lt;br/&gt;
                  sql: '.$sql.'&lt;br/&gt;');
    if($row = mysql_fetch_array($res, MYSQLI_ASSOC)){
        $_SESSION['successphoto'] = 1;
        return $row{first_name}.'_'.$row{last_name}.'_'.$row{client_id};
    }
    else{
        echo "There was an error while fetching the row.&lt;br/&gt;";
    }
  }
  
  class ImgResizer {
    private $originalFile = '';
    public function __construct($originalFile = '') {
        $this -&gt; originalFile = $originalFile;
    }
    public function resize($newWidth, $targetFile) {
        if (empty($newWidth) || empty($targetFile)) {
            return false;
        }
        $src = imagecreatefromjpeg($this -&gt; originalFile);
        list($width, $height) = getimagesize($this -&gt; originalFile);
        $newHeight = ($height / $width) * $newWidth;
        $tmp = imagecreatetruecolor($newWidth, $newHeight);
        imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
        if (file_exists($targetFile)) {
            unlink($targetFile);
        }
        imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious
    }
  }
  
  ?&gt;
  </code></pre>
  
  <p>Here is the snippet from upload_photo.php</p>
  
  <pre><code>echo '&lt;form enctype="multipart/form-data" action="uploader.php" method="POST"&gt;';
  echo '&lt;tr&gt;';
  //echo "&lt;td colspan='2'&gt;".$_GET['text']."&lt;/td&gt;";
  echo '&lt;/tr&gt;';
  echo '&lt;tr align="center"&gt;';
  echo '&lt;td colspan="2"&gt;';
  echo '&lt;input type="hidden" name="MAX_FILE_SIZE" value="5000000" /&gt;
          Choose a file to upload: &lt;input name="uploadedfile" type="file" accept="image/*"/&gt;&lt;br /&gt;
          &lt;input type="submit" value="Upload File" /&gt;
        &lt;/form&gt;';
  </code></pre>