ftp_put() not uploading

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
empiresolutions
Forum Newbie
Posts: 20
Joined: Tue Apr 11, 2006 10:39 am
Location: Portland, Or

ftp_put() not uploading

Post by empiresolutions »

ftp_put() is not working. this is what i have.

Code: Select all

$host = "www.site.com";
$ftp_user_name = "username";
$ftp_user_pass = "password";

// declair files
$remote_file = "ITS_BLI_0".$_POST['id'].".csv"; // root level
$file = "/upload/ITS_BLI_0".$_POST['id'].".csv"; // this file dir is root/manager/posts/

// connect to remote server
$hostip = gethostbyname($host);
$conn_id = ftp_connect($hostip);

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

// IMPORTANT!!! turn passive mode on
ftp_pasv ( $conn_id, true );

if ((!$conn_id) || (!$login_result)) {

    echo "FTP connection has failed!";
    echo "Attempted to connect to $host for user $ftp_user_name";
    die;

} else {

    // upload a file 
    if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { 

        echo "successfully uploaded $file<br>";

    } else {
        /** IM GETTING THIS ERROR **/
	echo "There was a problem while uploading $file to $host<br>";

    }
	   
    // close the connection
    ftp_close($conn_id);

}

  • I have done the following allready.
  • Used both FTP_ASCII and FTP_BINARY in ftp_put().
  • Passive mode must be on.
  • I have tried ftp_fput().

Is there a fix? Or maybe a way to view why its erroring on ftp_put().

thanks, [es]
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

No need to start another thread on the problem you were having before.

Use the other thread
Locked