Jump to content

FTP_Connect does'nt Work


lucie

Recommended Posts

Can you post the code?  Do you get errors?

 

 

Try this example's format: (PHP.net ftp_connect())

 

$ftp_server = "ftp.example.com";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

?>

Thanks for the support

Im using the same code from the PHP.NET,

The isuse is that the server doesnt have FTP enabled, do you know how to enable it?

 

when u log into ur control pannel u need to create an ftp account, how do u upload files you must have an ftp server installed otherwise u cant upload files, so use the ftp details u use to upload files to ur server.

function ftp(){
if($sys_local_server == $sys_live_site){ 
			if ($image_size > 0) {
				//Connect
				$ftp_con = ftp_connect($GLOBALS['sys_ftp_server']);
				if(!$ftp_con) echo("Failed to establish an FTP connection.");
				if(!ftp_login($ftp_con, $GLOBALS['sys_ftp_user'], $GLOBALS['sys_ftp_pass'])) echo("Failed to log in to FTP server.");

				//chmod directory
				if(!ftp_site($ftp_con, "CHMOD 0777 "."/".$folder)) echo("Failed to CHMOD directory.");

				//ftp the file
				$ftp_put = ftp_put($ftp_con, $folder."/".$filename, $image_filename, FTP_BINARY);			
				if(!$ftp_put) echo("Failed to FTP transfer file.");;			

				//chmod the file
				if(!ftp_site($ftp_con, "CHMOD 0644 ".$folder."/".$filename)) echo("Failed to reCHMOD directory.");
				//chmod directory back
				if(!ftp_site($ftp_con, "CHMOD 0755 ".$folder)) echo("Failed to reCHMOD directory.");

				if($ftp_put) return true;
				else return false;
			}
			else return false;
		}
}

 

this code can help you determin if you can at least log in, rember youy need to define foilder pass and username, folder will start from var/

Here is the code that Im using for FTP upload

 

function CheckFTPConnection($user_name, $ftp_user_pass){

$conn_id = ftp_connect("");

// Login with username and password

$ftp_user_name = ""

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

ftp_close($conn_id);

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

      $returnError = "Error";

    else

  $returnError = "";

// echo $returnError;

return  $returnError;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.