2009-12-09 6 views
0

PHP를 사용하여 FTP 서버에 파일을 업로드하려고하지만 업로드되지 않습니다.PHP를 사용하여 ftp 서버에 파일을 업로드 할 수 없습니다

코드 :

$response =<<<RESPONSE 
    <cdm:Response> 
    <cdm:header exportTime="{$export_time}" baseVersion="{$baseline_snapshot_id}" version="{$this->snapshot_id}"> 
      <cdm:countryCode>{$this->domain}</cdm:countryCode> 
      <cdm:description>{$description}</cdm:description> 
      <cdm:environment>{$destination}</cdm:environment> 
      <cdm:name>{$name}</cdm:name> 
    </cdm:header> 
    <cdm:Status>{$this->status}</cdm:Status> 
    </cdm:Response> 
    RESPONSE; 

    $handler = fopen($log_file_name, 'w'); 
    fwrite($handler, $response); 
    fclose($handler); 

    $server = "adoshi.dev.com"; 
    $ftp_user_name = "adoshi"; 
    $ftp_user_pass = "*******"; 
    #$source = $handler; 
    $mode = "FTP_ASCII"; 
    $dest = "/home/adoshi/ftp_folder"; 
    $connection = ftp_connect($server); 
    $login = ftp_login($connection, $ftp_user_name, $ftp_user_pass); 
    if (!$connection || !$login) { die('Connection attempt failed!'); } 
    $upload = ftp_nb_put($connection, $dest, $handler, $mode); 
    if (!$upload) { echo 'FTP upload failed!'; } 
    ftp_close($connection); 

나는 적절한 모든 로그인 자격 증명을 제공하고 PHP를 사용하여 원격 서버에 업로드되지 않는 이유 때문에 여전히 궁금했다.

모든 안내는 매우 높이 평가됩니다.

+0

같은 파일 이름이 필요하다고 업로드 할 파일 핸들러를 작성해야 해달라고? –

+1

어떤 일이 발생하거나 일어나지 않습니까? 어떤 오류 메시지가 나타 납니까? 윗부분의 내용은 무엇입니까? 누구든지 당신을 도울 수 있도록 좀 더 자세한 내용을 제공해야합니다. –

+0

아, 윗부분에 맞춰서 첫 줄을 보지 못했습니다. –

답변

0

당신은 그냥 파일의 경로와 오류를받을 수 있나요이

$destFile= "test.htm"; 
$lokal_file = "test.htm"; 
$upload = ftp_put ($connection_id, $destFile, $lokal_file, FTP_ASCII); 
+0

나는 이것을하려고 노력했다. 그러나 아직도 나로 생각하지 않고있다. 문제는 어떤 종류의 오류도 발생하지 않으므로 실제로 일어나고있는 것을 추적 할 수 없습니다. – Rachel

+0

이 스크립트를 스크립트에 추가하려고 했습니까? error_reporting (E_ALL); ini_set ('display_errors', '1'); – streetparade

+0

나는 이것을했지만 여전히 오류가 없으므로 왜 이런 일이 일어나고 있는지 궁금합니다 ... – Rachel

관련 문제