Uploading file to ftp using ftp_connect fails
<p>I am trying to upload product to my server using ftp. However I am given the following error message: 
FTP connection has failed!Attempted to connect to .....</p>

<p>Below is php script:</p>

<pre><code>if (isset($submit)){

//connect to ftp server
$ftp_server="123456shop.bugs3.com";
//ftp user name
$ftp_user_name="u12345";
//ftp username password
$ftp_user_pass="abcde";

$con_id=ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($con_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
   echo "FTP connection has failed!";
   echo "Attempted to connect to $ftp_server for user $ftp_user_name....";
   exit;
} else {
   echo "Connected to $ftp_server, for user $ftp_user_name".".....";
}



$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/jpg"))
&amp;&amp; ($_FILES["file"]["size"] &lt; 2000000)
&amp;&amp; in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] &gt; 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "&lt;br&gt;";
echo "Type: " . $_FILES["file"]["type"] . "&lt;br&gt;";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;";

if (file_exists("../product_images/" . $_FILES["file"]["name"]))
  {
  echo $_FILES["file"]["name"] . " already exists. ";
  }
else
  {
  $filep=$_FILES['file']['tmp_name'];
  // upload the file
$upload = ftp_put($conn_id, '/home/u408392962/public_html/product_images/', $filep,     FTP_BINARY);

// check upload status
if (!$upload) {
   echo "FTP upload has failed!";
} else {
   echo "Uploaded $name to $ftp_server ";
}
  /*move_uploaded_file($_FILES["file"]["tmp_name"],
  "../product_images/" . $_FILES["file"]["name"]);
  echo "Stored in: " . "../product_images/" . $_FILES["file"]["name"];*/

  $sql = "INSERT INTO product  (name,price,description,type,qty,IsSpecial,categoryID,IsNew) VALUES ('$_POST[name]', '$_POST[price]', '$_POST[description]','$_POST[type]','$_POST[qty]','$_POST[IsSpecial]','$_POST[categoryID]','$_POST[IsNew]')";
  $recordset2 = mysql_query( $sql ) or die(mysql_error());
  echo "&lt;script language=javascript&gt;alert('SUCCESSFULLY Add!')&lt;/script&gt;";
  echo "&lt;SCRIPT language='Javascript'&gt;
           document.location=\"\list.php\";
       &lt;/SCRIPT&gt;"; 
  }
}
}
else
{
echo "Invalid file";
}

}
</code></pre>

<p>Can anyone help me with this?
Thanks a lot!!!</p>
