ftpput php,PHP: ftp_put - Manual

Here is the Code I am using for the same function with more flexibility in static code:

$name = "FILE NAME";

$filename = "FILE NAME WITH FULL PATH";

//-- Code to Transfer File on Server Dt: 06-03-2008 by Aditya Bhatt --//

//-- Connection Settings

$ftp_server = "IP ADDRESS"; // Address of FTP server.

$ftp_user_name = " SERVER USERNAME"; // Username

$ftp_user_pass = " SERVER PASSWORD"; // Password

$destination_file = " SERVER FILE PATH TO UPLOAD VIA FTP_PUT"; //where you want to throw the file on the webserver (relative to your login dir)

$conn_id = ftp_connect($ftp_server) or die("

Couldn't connect to $ftp_server

");        // set up basic connection

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("

You do not have access to this ftp server!

");   // 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 "

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
";

}

$upload = ftp_put($conn_id, $destination_file.$name, $filename, FTP_BINARY);  // upload the file

if (!$upload) {  // check upload status

echo "

FTP upload of $filename has failed!


";

} else {

echo "

Uploading $name Completed Successfully!


";

}

ftp_close($conn_id); // close the FTP stream

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值