2017-05-22 14 views
0

도와 주실 수 있습니까? 응용 프로그램 내부의 폴더에 파일을 복사하려고합니다. 이 스크립트는 나는 그것이 오류가 표시됩니다의 cPanel 서버에서 실행하지만 때 내 로컬 컴퓨터에 노력하고 있습니다 여기에 FTP 서버에서 PHP를 사용하여 Cpanel로 파일 복사

내가

$folder_path = "192.xx.xx.xx\TMS"; 
    $local_file = "CurrentFile\Inbound.xls"; 
    $server_file = "CurrentFile\Inbound.xls"; 
    //-- Connection Settings 
    $ftp_server = "192.xx.xx.xx"; // Address of FTP server. 
    $ftp_user_name = "FTP server username"; // Username 
    $ftp_user_pass = "FTP server Password"; // Password 

    $target = 'CurrentFile'; 
    if (!file_exists($target)) 
    { 
      die("Target directory doesn't exist."); 
    } 
    else if (!is_writable($target)) 
    { 
      die("Insufficient privileges to write to the target directory!"); 
    } 
    // set up basic connection 
    $conn_id = ftp_connect($ftp_server); 
    // login with username and password 
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
    // try to download $server_file and save to $local_file 
    if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) 
    { 
     echo "Successfully written to $local_file\n"; 
    } 
    else 
    { 
     echo "There was a problem\n"; 
    } 

    function fileExists($path) 
    { 
     return (@fopen($path,"r")==true); 
    } 
    ftp_close($conn_id); 
테스트 스크립트는 "ftp_login은() 매개 변수 1, 부울 주어진 자원이 될 것으로 기대"

스크립트가 FTP 서버에 연결하지 못하고 있다고 생각합니다. 연결을 만든 직후에 이것을 추가하면 "연결 실패"가 반환됩니다.

if(!$conn_id) { 
die("Connection failed!"); 
} 

답변

0

나는이 사용하고 있지 않다 그러나 나는이 튜토리얼 ftp_login expects parameter 1 to be a resource에 가서 나를 당신의 응답이

+0

감사합니다 아 미트 일어날 알려 제안! 불행히도,이 튜토리얼은 내가 필요로하는 것이 아니다. 이 스크립트는 FTP 서버에 로그인하기 전에 연결이 성공했는지 확인하여 다음과 같은 오류를 방지합니다. 경고 : ftp_login()은 매개 변수 1이/home/content/98/10339998/html/upload에 지정된 부울 값일 것으로 예상합니다. .php on line 65 FTP 연결에 오류가 발생했습니다! thelegendmaker.net에 연결을 시도했습니다. " – Johny