zero-perfoliate
zero-perfoliate

Author Topic: PHP: UPload to another ftp  (Read 427 times)

Offline ejuniour

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
PHP: UPload to another ftp
« on: July 22, 2010, 08:54:40 AM »
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: [Select]
<?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.";
?>

Offline annyphp

  • PHP Workers
  • **
  • Posts: 15
  • Karma: +0/-0
Re: PHP: UPload to another ftp
« Reply #1 on: December 06, 2010, 05:40:48 PM »
You may check PHP ftp
Best regards!

 

zero-perfoliate