- 相關(guān)推薦
php使用ftp函數(shù)實(shí)現(xiàn)簡單上傳功能
php使用ftp函數(shù)實(shí)現(xiàn)的一個簡單的文件上傳功能,供初學(xué)者參考。就跟隨百分網(wǎng)小編一起去了解下吧,想了解更多相關(guān)信息請持續(xù)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!
php ftp函數(shù) 文件上傳。
復(fù)制代碼 代碼如下:
<?php
/**
ftp上傳文件
link:www.jquerycn.cn
date:2013/2/25
*/
$ftp_server = "192.168.8.8";
$ftp_user = "test123";
$ftp_pass = "yourpassword";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
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";
}
// try to login
$filename=date('Ymd').".xml";
$source_file="/var/mydata/".$filename; //源地址
echo $source_file;
$destination_file="/admin/ftplog/".$filename; //目標(biāo)地址
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY) or die("Couldn't connect to $ftp_server");
ftp_quit($conn_id);
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
ftp_close($conn_id);
?>
【php使用ftp函數(shù)實(shí)現(xiàn)簡單上傳功能】相關(guān)文章:
輔助功能模塊FTP站點(diǎn)管理實(shí)現(xiàn)方法10-27
php上傳與刪除圖片的簡單范例10-13
php編程實(shí)現(xiàn)簡單的網(wǎng)頁版計(jì)算器功能08-29
PHP實(shí)現(xiàn)搜索查詢功能的方法技巧08-01