File "php_ftp_put01.php"

Full Path: /home/analogde/www/Administratif/FTP/Workarea/php_ftp_put01.php
File size: 1.17 KB
MIME-type: text/x-php
Charset: utf-8

<?php

function uploadFTP($server, $username, $password, $local_file, $remote_file){
    // connect to server
    $connection = ftp_connect($server);

    // login
    if (@ftp_login($connection, $username, $password))
    {
        // successfully connected
        echo "OK";

    }else{
        return false;
    }

    ftp_pasv( $connection, true );

    $path = "/www/2024_PHP/2024_PHP_12_11_2024/FTP";


        echo $path ."<br>";

        ///home/analogde/www/2024_PHP/2024_PHP_02_11_2024/

        $contents = ftp_nlist($connection, $path);
        // output $contents
        var_dump($contents);

    ftp_put($connection, $remote_file, $local_file, FTP_BINARY);


    // Charge un fichier
    if (ftp_fput( $connection, $remote_file, $local_file, FTP_ASCII)) 
    {
    echo "Le fichier a té chargé avec succès\n";
   } else {
    echo "Il y a eu un problème lors du chargement du fichier\n";
   }

    
    ftp_close($connection);
    return true;
}


    $ftpServer = 'ftp.cluster011.ovh.net';
    $ftpUser = 'analogde';
    $ftpPass = 'rainbow';

    uploadFTP( $ftpServer, $ftpUser, $ftpPass, "f:\\2024\\IMG.jpg", "/www/2024_PHP/2024_PHP_12_11_2024/FTP/aqwzsximage.jpg");

?>