title: ftp_put uploading zero byte files
body: <p>I'm make a quick PHP script to run locally on our computers in the office. The idea is so we can manage a competition from our office without allowing online access. The FTP upload is so we can upload the file to our FTP account.</p>
  
  <p>I've got the following HTML form code:</p>
  
  <pre><code>&lt;form method="post" id="new_competition" enctype="multipart/form-data"&gt;
              &lt;?php if(isset($error)){ echo "&lt;p class='error'&gt;$error&lt;/p&gt;"; } ?&gt;
              &lt;?php if(empty($done)){ ?&gt;
                  &lt;h1&gt;Love Hearts Competition Entry&lt;/h1&gt;
                  &lt;label&gt;Opening Date: &lt;/label&gt;&lt;input type="date" name="opening_date" value="&lt;?= $opening_date; ?&gt;" placeholder="Opening Date" required&gt;
                  &lt;label&gt;Closing Date: &lt;/label&gt;&lt;input type="date" name="closing_date" value="&lt;?= $closing_date; ?&gt;" placeholder="Closing Date" required&gt;
                  &lt;label&gt;Title: &lt;/label&gt;&lt;input type="text" name="title" value="&lt;?= $title; ?&gt;" placeholder="Competition Title" required&gt;
                  &lt;label&gt;Question: &lt;/label&gt;&lt;textarea name="question" placeholder="Competition Question" required&gt;&lt;?= $question; ?&gt;&lt;/textarea&gt;
                  &lt;div class="answers"&gt;
                      &lt;?php if(!empty($answers)){
                          foreach ($answers as $answer) {?&gt;
                              &lt;div class="answer"&gt;&lt;label class="answer_label"&gt;Answer: &lt;/label&gt;&lt;input type="text" name="answer[]" value="&lt;?= $answer; ?&gt;" placeholder="Answer text" required/&gt;&lt;div class="remove_answer"&gt;X&lt;/div&gt;&lt;/div&gt;
                          &lt;?php } 
                      } else { ?&gt;
                      &lt;div class="answer"&gt;&lt;label class="answer_label"&gt;Answer: &lt;/label&gt;&lt;input type="text" name="answer[]" value="" placeholder="Answer text" required/&gt;&lt;div class="remove_answer"&gt;X&lt;/div&gt;&lt;/div&gt;
                      &lt;?php } ?&gt;
                  &lt;/div&gt;
                  &lt;div class="add_answer"&gt;Add another answer&lt;/div&gt;
                  &lt;label for="terms"&gt;Terms &amp;amp; Conditions File&lt;/label&gt;&lt;input type="file" name="terms" placeholder="Terms &amp;amp; Conditions File" required /&gt;
                  &lt;input type="submit" value="Add Competition" name="submit" id="submit" /&gt;
              &lt;?php } else { ?&gt;
                  &lt;p class='done'&gt;Successfully added competition&lt;/p&gt; 
              &lt;?php } ?&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>And, as you can see, I have used the proper enctype.</p>
  
  <p>My PHP Code is as follows:</p>
  
  <pre><code>if($_POST['submit']){
  
      $opening_date = $_POST['opening_date'];
      $closing_date = $_POST['closing_date'];
      $title = $_POST['title'];
      $question = $_POST['question'];
      $answers = $_POST['answer'];
      $terms = $_FILES['terms']['name'];
      $tmp = $_FILES['terms']['tmp_name'];
  
      $date_diff = (date_diff(date_create($opening_date), date_create($closing_date)));
      if(!$date_diff-&gt;invert){
          if(count($answers) &gt; 1){
              $ftpCon = ftp_connect($host_ip);
              $ftpLogin = ftp_login($ftpCon, $host_login, $host_pswd);
              $remoteURL = '/public_html/competition_terms/'.$terms;
  
              // Upload the file!
              $ftpUpload = ftp_put($ftpCon, $remoteURL, $tmp, FTP_BINARY) or die("Unable to load upload file");
  
  
              if($ftpUpload){
                  $answers_json = json_encode($answers);
  
                  $db = mysql_connect($db_host, $db_user, $db_pwd) or die('cannot connect to db: '.mysql_error());
                  $db = mysql_select_db('lovehear_competitions') or die(mysql_error());
  
                  $query = mysql_query("INSERT INTO competitions (opening_date, closing_date, title, question, answers, terms) VALUES ('$opening_date', '$closing_date', '$title', '$question', '$answers_json', '".str_replace("public_html/", "", $remoteURL)."')") or die(mysql_error());
                  $done = true;
              } else {
                  $error = "Unable to upload file.";
              }
              ftp_close($ftpCon); 
          } else {
              // Only one answer
              $error = "You must give more than one answer";
          }
      } else {
          // Closing date before opening date
          $error = "You must have a closing date that ends after the opening date.";
      }
  }
  </code></pre>
  
  <p>The file is created on my server, under "public_html/competition_terms/" but the file contains zero bytes.</p>
  
  <p>Does anyone know why? I can't seem to see any useful help online and the PHP Docs don't seem to mention any restriction for local to remote uploading.</p>