Temel kullanım

Örnek 1 - FTP örneği

<?php
// Bağlantıyı kuralım
$bt ftp_connect($ftp_sunucu);

// kullanıcı adı ve parola ile oturum açalım
$bağlantı ftp_login($bt$ftpci$ftpci_parolası);

// bağlantıyı sınayalım
if ((!$bt) || (!$bağlantı)) {
    echo 
"FTP bağlantısı kurulamadı!";
    echo 
"$ftpci için $ftp_sunucu sunucusuna bağlanmaya çalışılıyordu.";
    exit;
} else {
    echo 
"$ftpci için $ftp_sunucu sunucusuna bağlantı kuruldu.";
}

// Dosyayı sunucuya yükleyelim
$yükleme ftp_put($bt$hedef$kaynakFTP_BINARY);

// Duruma bakalım
if (!$yükleme) {
    echo 
"FTP dosya yüklemesi başarısız oldu!";
} else {
    echo 
"$kaynak dosyası $ftp_sunucu sunucusuna ";
    echo 
"$hedef dosyası olarak yüklendi.";
}

// FTP akımını kapatalım
ftp_close($bt);
?>

add a note add a note

User Contributed Notes 2 notes

up
-7
clemensroth2004 at yahoo dot de
14 years ago
My FTP-Server always responded "bool(false)" instead of presenting me a directory-listing. I had to add
ftp_pasv($conn_id, true); right after the $login_result = ftp_login(...); line.
After that it just worked fine.
up
-14
kane dot prajakta at gmail dot com
14 years ago
I used following code successfully to connect to "lftp" server and see the complete dir listing.
also ftp_pasv($conn_id, true); trick works fine for lftp server :)

<?php
// set up basic connection
$ftp_server = "example.com";
$conn_id = ftp_ssl_connect($ftp_server);

// login with username and password
$ftp_user_name = "myuser";
$ftp_user_pass = "mypass";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
// check connection
if ((!$conn_id) || (!$login_result)) {
        echo
"FTP connection has failed!";
        echo
"Attempted to connect to $ftp_server for user $ftp_user_name";
        exit;
    } else {
        echo
"Connected to $ftp_server, for user $ftp_user_name";
    }

$buff = ftp_rawlist($conn_id, '.');
var_dump($buff);
ftp_close($conn_id); 
?>

Thanks ,
Prajakta
To Top