在ftp_connect中使用ip地址

时间:2014-05-05 05:45:09

标签: php ftp ip-address

我正在尝试连接到没有任何域名的服务器,例如' abc.com'。相反,我必须通过其IP地址访问它。 我尝试在这里使用ftp,但ftp_connect()不支持IP地址。 以下是我试过的代码..

<?php 
echo $ftp_server="182.8.87.89"; 
$ftp_user_name=""; 
$ftp_user_pass=""; 
$file = "new.txt";//tobe uploaded 
$remote_file = "test/heelo.txt"; 

// set up basic connection

$conn_id = ftp_connect($ftp_server); 
//echo 21;
// login with username and password 
echo $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die(); 

// upload a file 
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { 
echo "successfully uploaded $file\n"; 
exit; 
} else { 
echo "There was a problem while uploading $file\n"; 
exit; 
} 
// close the connection 
ftp_close($conn_id); 

我得到的错误是Warning: ftp_login() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\te\seperateupload.php on line 26

0 个答案:

没有答案