Pages: [1]   Go Down
Author Topic: PHP: UPload to another ftp  (Read 110 times)
ejuniour
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2


« on: July 21, 2010, 11:54:40 PM »

HI,
There is i want to know how to make a php scripts:
1st. sort list of files in directory on basis of Modified time.


2.  ho to convert the script below to upload only files whose name are submitted not all files, i mean it should be converted that  it upload only files whose name are  submited.


Code:
<?php
$FTP_HOST 
="ftp.br.geocities.com"
$FTP_USER ="bobfrank";
$FTP_PW   ="mypasswd";
$FTP_ROOT_DIR="/";
$LOCAL_SERVER_DIR  "images/";
$FTP_DIR "mydir/";
$handle=opendir($LOCAL_SERVER_DIR);
while ((
$file readdir($handle))!==false)
{
    if(!
is_dir($file)){
        
$f[]="$file";        
      }
}
closedir($handle);
sort($f);
$count=0;
$mode FTP_BINARY// or FTP_ASCII
$conn_id ftp_connect($FTP_HOST); 
if(
ftp_login($conn_id$FTP_USER$FTP_PW)){
    print 
"from: ".$LOCAL_SERVER_DIR."<br>";
    print 
"to: ".$FTP_HOST.$FTP_ROOT_DIR.$FTP_DIR."<br>";
    
ftp_pwd($conn_id);
    
ftp_mkdir($conn_id,$FTP_DIR);
    
ftp_chdir($conn_id,$FTP_DIR); 
    foreach(
$f as $files) {
        
$from fopen($LOCAL_SERVER_DIR.$files,"r");     
        if(
ftp_fput($conn_id$files$from$mode)){
            
$count +=1;
            print 
$files."<br>";
        }
    }
    
ftp_quit($conn_id);
}
print 
"upload : $count files.";
?>
Report to moderator   Logged

Pages: [1]   Go Up
Print
 
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC | Theme Kani By Fussilet

Page created in 0.04 seconds with 21 queries.