Top 10 Daily Top Selling Deals - Official TigerDirect.com Deals

Official TigerDirect.com Coupons

Official TigerDirect.com Coupons

Tuesday, March 1, 2011

ftp_connect wont connect


hi,

i am trying to move a file from an off site to an on site server but am not having any luck, when i try and use ftp_connect if returns an error. is there something i am doing wrong?

PHP Code:

<?php 
if (($_FILES["file"]["size"] < 2000000))
  {
  if (
$_FILES["file"]["error"] > 0)
    {
    echo 
"Return Code: " $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    if (
file_exists("upload/" $_FILES["file"]["name"]))
      {
      }
    else
      {
        
move_uploaded_file($_FILES["file"]["tmp_name"],
        
"upload/" $_FILES["file"]["name"]);
        
$name $_FILES["file"]["name"];
        echo 
$name;
        
$file "upload/$name";
        
$destination_file "/web_orders/".$name;
        
$ftp_server "207.119.91.77";  //address of ftp server (leave out ftp://)
        
$ftp_user_name "****************"// Username
        
$ftp_user_pass "***";   // Password
        
echo "$ftp_user_name, $ftp_user_pass, $ftp_server";

          
$conn_id ftp_connect('207.119.91.77') or die("<span style='color:#FF0000'><h2>Couldn't connect to $ftp_server</h2></span>");        // set up basic connection
          #print_r($conn_id);
          
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass) or die("<span style='color:#FF0000'><h2>You do not have access to this ftp server!</h2></span>");   // login with username and password, or give invalid user message
          
if ((!$conn_id) || (!$login_result)) {  // check connection
                 // wont ever hit this, b/c of the die call on ftp_login
                 
echo "<span style='color:#FF0000'><h2>FTP connection has failed! <br />";
                 echo 
"Attempted to connect to $ftp_server for user $ftp_user_name</h2></span>";
                 exit;
             } else {
             
//    echo "Connected to $ftp_server, for user $ftp_user_name <br />";
          
}

      
$upload ftp_put($conn_id$destination_file$fileFTP_BINARY);  // upload the file
      
if (!$upload) {  // check upload status
         
echo "<span style='color:#FF0000'><h2>FTP upload of $file has failed!</h2></span> <br />";
      } else {
         echo 
"<span style='color:#339900'><h2>Uploading $file Completed Successfully!</h2></span><br /><br />";
      }
      
ftp_close($conn_id); // close the FTP stream
      
}
    }
  }
?>

No comments:

Post a Comment

Computers-and-Technology Articles from EzineArticles.com