Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    7

    copiare file via ftp da server a server

    Ciao, sto sclerando da giorni per copiare dei file dallo stesso ftp server tra due directory diverse.
    Codice PHP:
    <?
    //FTP
    //Connect to the FTP server
    $ftpstream = @ftp_connect('localhost');
    //Login to the FTP server
    $login = @ftp_login($ftpstream'user''pass');

    if(
    $login) {     //We are now connected to FTP server.
        //Create a directory on your website and set permission where needed
        
    @ftp_mkdir($ftpstream$destpath);
        
    ftp_site($ftpstream,"CHMOD 0777 $destpath");

        
    $file $sourcepath 'index.php';
        
    $fp fopen($file'r');

        
    //Upload the temporary file to server
        
    @ftp_fput($ftpstream$file$fpFTP_ASCII);
        
    }
    //Close FTP connection
    ftp_close($ftpstream);
    Il vaore di $sourcepath è preso con realpath(".")... dove sbaglio? Tra l'altro non ho nessun errore di ritorno sul server! :-( (sarà qualche settaggio del php.ini?).
    Il file da copiare dovrebbe finire sotto la nuova cartella creata $destpath (che viene creata correttamete)

    ?>

  2. #2
    se non hai nessun errore è perchè prima delle funzioni hai messo il: @
    1. levalo
    2. metti in testa agli script error_reporting(E_ALL);

  3. #3
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    7
    Così?

    Codice PHP:
    <?
    error_reporting
    (E_ALL);
    //FTP
    //Connect to the FTP server
    $ftpstream ftp_connect('localhost');
    //Login to the FTP server
    $login ftp_login($ftpstream'user''pass');

    if(
    $login) {     //We are now connected to FTP server.
        //Create a directory on your website and set permission where needed
        
    ftp_mkdir($ftpstream$destpath);
        
    ftp_site($ftpstream,"CHMOD 0777 $destpath");

        
    $file $sourcepath 'index.php';
        
    $fp fopen($file'r');

        
    //Upload the temporary file to server
        
    ftp_fput($ftpstream$file$fpFTP_ASCII);
        
    }
    //Close FTP connection
    ftp_close($ftpstream);

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.