2010-06-06 6 views
3

FTP 서버에 파일을 업로드하는 작은 PHP 함수를 작성하려고하지만 동일한 오류가 계속 발생하지만 문제를 찾아 가서 문제를 찾을 수 없으며 사용자가 저를 도울 수 있기를 바랍니다. 여기 ...PHP ftp 업로드 문제

경고 : ftp_put() [function.ftp-put] : 데이터 연결을 빌드 할 수 없습니다 : 호스트 할 경로가 없습니다.

파일이 FTP 서버에서 생성되었지만 0 바이트입니다.

<?php 
$file = "test.dat"; 

$ftp_server="ftp.server.com"; 
$ftp_user = "myname"; 
$ftp_pass = "mypass"; 
$destination_file = "test.dat"; 


$cid=ftp_connect($ftp_server); 
if(!$cid) { 
    exit("Could not connect to server: $ftp_server\n"); 
} 

$login_result = ftp_login($cid, $ftp_user, $ftp_pass); 
if (!$login_result) { 
    echo "FTP connection has failed!"; 
    echo "Attempted to connect to $ftp_server for user $ftp_user"; 
    exit; 
} else { 
echo "Connected to $ftp_server, for user $ftp_user"; 
} 

$upload = ftp_put($cid, $destination_file, $file, FTP_BINARY); 
if (!$upload) { 
    echo "Failed upload for $source_file to $ftp_server as $destination_file<br>"; 
    echo "FTP upload has failed!"; 
} else { 
    echo "Uploaded $source_file to $ftp_server as $destination_file"; 
} 

ftp_close($cid); 
?> 

답변

7

내가 사용 수동 모드에서 FTP를 넣어 잊었 :

ftp_pasv($cid, true); 
다음

코드입니다