title: Warning: ftp_put() expects parameter 1 to be resource, boolean given in
body: <p>I am trying to do a form that upload a few fields, and 3 images. The images will be uploaded via FTP, there is a problem connecting to ftp with ftp_connect() when the php is uploaded to remote server. It couldn't connect to server when the php is in the shared host. But when the php is in the localhost, it display no error. I am now trying to make this work on Localhost and ftp_put the images into the remote server first, to isolate the error.
  At the moment i am getting this error. </p>
  
  <pre><code>Warning: ftp_put() expects parameter 1 to be resource, boolean given in line 69
  </code></pre>
  
  <p>Which is this  <code>ftp_put($login,"abc.info/$photo",$_FILES["file"]["tmp_name"][$i],FTP_ASCII)</code></p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', 1); error_reporting(E_ALL);
  
  ob_start();
  session_start();
  include 'connect.php';
  include 'Agentftpconnect.php';
  if(!isset($_SESSION['username']))
  {
      header("Location: home.php");
      exit;
  }
  
  
  if ($_POST)
  {
   //get form data
  
  
  
   $Listingname = addslashes(strip_tags($_POST['Listingname']));
   $Location = addslashes(strip_tags($_POST['Location']));
   $nobed = addslashes(strip_tags($_POST['nobed']));
   $zip = addslashes(strip_tags($_POST['zip']));
   $price = ($_POST['price']);
  
  
   if (!$Listingname||!$nobed||!$Location||!$zip||!$price)
      die ("Please fill out all fields"); 
      else 
  
  
  
      for($i=0;$i&lt;3;$i++)
      {
  
  
  if ((($_FILES["file"]["type"][$i] !== "image/gif")
  || ($_FILES["file"]["type"][$i] !== "image/jpeg")
  || ($_FILES["file"]["type"][$i] !== "image/jpg")
  || ($_FILES["file"]["type"][$i] !== "image/pjpeg")
  || ($_FILES["file"]["type"][$i] !== "image/x-png")
  || ($_FILES["file"]["type"][$i] !== "image/png"))
      &amp;&amp; ($_FILES["file"]["size"][$i] &gt; 400000))
  die("File is not correct");
  
  else{
  
    if ($_FILES["file"]["error"][$i] &gt; 0)
      {
      echo "Return Code: " . $_FILES["file"]["error"][$i] . "&lt;br&gt;";
      }
    else
      {
      echo "Upload: " . $_FILES["file"]["name"][$i] . "&lt;br&gt;";
      echo "Size: " . ($_FILES["file"]["size"][$i] / 1024) . " kB&lt;br&gt;";
      echo "Temp file: " . $_FILES["file"]["tmp_name"][$i] . "&lt;br&gt;";
      echo "&lt;br&gt;";
  
      if (file_exists("abc.info/rent" . $_FILES["file"]["name"][$i]))
        {
        die($_FILES["file"]["name"][$i] . " already exists please add another file, or change the name ");
        }
  
      else
  
        {
          $photo=$_FILES["file"]["name"][$i];
        ftp_put($login,"abc.info/$photo",$_FILES["file"]["tmp_name"][$i],FTP_ASCII) or die("Can not upload");
        echo "Stored in: " . "abc.info/rent/" . $_FILES["file"]["name"][$i];
        }
      }
  }
  
  
  
  }
  
      {
        $photo0=$_FILES["file"]["name"][0];
          $photo1=$_FILES["file"]["name"][1];
           $photo2=$_FILES["file"]["name"][2];
         $username=$_SESSION['username'];
  
             //register into database
              mysqli_query($con,"INSERT INTO Listing (username,Listingname,Location,nobed,zip,price,pic1,pic2,pic3) VALUES 
                  ('$username','$Listingname','$Location','$nobed','$zip','$price','$photo0','$photo1','$photo2');") or die(mysqli_error());
  
  
              echo "Listing Added";
      }        
  
         }
  
  
  
  
  
  else
  {
  
  ?&gt;
  
  &lt;form action="Submitlisting8.php" method="post"
  enctype="multipart/form-data"&gt;
  Listing Name:&lt;br /&gt;
  &lt;input type='text' name='Listingname'&gt;&lt;p /&gt;
  Location:&lt;br /&gt;
  &lt;input type='text' name='Location'&gt;&lt;p /&gt;
  Number of Beds:&lt;br /&gt;
  &lt;input type='test' name='nobed'&gt;&lt;p /&gt;
  Zip:&lt;br /&gt;
  &lt;input type='text' name='zip'&gt;&lt;p /&gt;
  Price:&lt;br /&gt;
  &lt;input type='text' name='price'&gt;&lt;p /&gt;
  
  
  &lt;label for="file"&gt;Pic1(File must be exceed 4mb):&lt;/label&gt;
  &lt;input type="file" name="file[]" id="file[]"&gt;&lt;br&gt;
  &lt;label for="file"&gt;Pic2(File must be exceed 4mb):&lt;/label&gt;
  &lt;input type="file" name="file[]" id="file[]"&gt;&lt;br&gt;
  &lt;label for="file"&gt;Pic3(File must be exceed 4mb):&lt;/label&gt;
  &lt;input type="file" name="file[]" id="file[]"&gt;&lt;br&gt;
  &lt;br&gt;
  &lt;input type='submit' name='submit' value='Submit'&gt;
  &lt;/form&gt;
  
  &lt;FORM METHOD="LINK" ACTION="agentaccount.php"&gt;
  &lt;INPUT TYPE="submit" VALUE="Back to Account"&gt;
  &lt;/form&gt;
  
  &lt;?php
  
  }
  
  
  
  ?&gt;
  </code></pre>
  
  <p>FTPconnect</p>
  
  <pre><code>&lt;?php
  $ftp_user_name='name';
  $ftp_user_pass='pass';
  $connection = 'ftp.abc.info';
  
  $connect = ftp_connect($connection) or die("Couldn't connect to $connection"); 
  $login=ftp_login($connect, $ftp_user_name, $ftp_user_pass);
  if(!$login)
  {
      die("But failed at login Attempted to connect to $connection for user $ftp_user_name....");
  }
  
  
  ?&gt;
  </code></pre>