Results 1 to 2 of 2

Thread: Copying files from another server

  1. #1
    Join Date
    Sep 2004
    Location
    Martil
    Age
    31
    Posts
    18,723
    Likes (Given)
    0
    Likes (Received)
    455
    Dislikes (Given)
    0
    Dislikes (Received)
    0
    Rep Power
    109881

    Default Copying files from another server

    This script will allow you to copy files from other server that you own. You only need to specify the ftp host, ftp user name, ftp password, and the folder where the files to be copied are stored. You need to upload this script in the folder where you want to transfer the files. Be sure that the folder where you want to transfer the files is in chmod 777.


    PHP Code:
    <?
    $HOST
    =”domain.com”//change domain.com with your ftp host
    $UN=”username”//ftp user name
    $PW=”pass”//ftp password
    $DIR=”www/location///location of files you want to copy

    $conn ftp_connect($HOST);
    if(!
    $conn) {
    exit(
    ”Could not connect to server$HOST\n”);
    }else{
    echo 
    “connected”;
    }

    //exit;
    if(!ftp_login($conn,$UN,$PW)) {

    ftp_quit($conn);
    exit(
    ”Could not log in\n”);
    }

    echo 
    “current directory is ” .ftp_pwd($conn);

    ftp_chdir($conn,$DIR);

    echo 
    <p>Now the current directory is ” .ftp_pwd($conn);

    $files ftp_nlist($conn,.);

    for(
    $i=0;$i<count($files);$i++) {
    echo 
    “Saving $files[$i] <br>;

    if(!
    ftp_get($conn,$files[$i],$files[$i],FTP_BINARY)) {
    echo 
    “Could not download {$files[$i]}\n”;
    }
    }

    ftp_quit($conn);
    ?>
    -
    -


    **FAQ**

    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ]


  2.    Advertissements


  3. #2
    Join Date
    Jan 2009
    Age
    34
    Posts
    6
    Likes (Given)
    0
    Likes (Received)
    0
    Dislikes (Given)
    0
    Dislikes (Received)
    0
    Rep Power
    10

    Default

    not bad for the codes

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •