ftp_put boş bir dosya yükler

0 Cevap php

Ben bir windows sunucuya ftp_put üzerinden bir dosya yüklemeye çalışıyorum.

aşağıdaki gibi benim kod:

    $date           = date('ymd');
    $file_name      = $date.'.csv';
    $file_location  = 'D:/inetpub/wwwroot/website.com/html/assets/'.$file_name;

//set up basic connection
$conn_id = ftp_connect(FTP_HOST, FTP_PORT);

// login with username and password
$login_result = ftp_login($conn_id, FTP_USER, FTP_PASS);

// check connection
if ((!$conn_id) || (!$login_result)) { 
    echo "FTP connection has failed!"; 
    exit;
}  else { 
    echo "Connected to FTP Server";
}

$upload = ftp_put($conn_id, $file_name, $file_location, FTP_ASCII);

// check upload status
if (!$upload) { 
    echo "FTP upload has failed!"; 
} else { 
    echo "File Uploaded";
}

// close the FTP stream 
ftp_close($conn_id); 

Ben filezilla kullanarak elle dosyası yüklerseniz, mükemmel çalışıyor. Ben yukarıdaki kodu kullanırsanız, bu boş bir dosya oluşturur.

0 Cevap