FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 14th, 2003, 10:04 PM
HitByASquirrel HitByASquirrel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 HitByASquirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to HitByASquirrel Send a message via Yahoo to HitByASquirrel
Question FTP and PHP....

anyone know how to downlaod an entire directory via FTP with PHP?

thanks

Reply With Quote
  #2  
Old June 14th, 2003, 11:55 PM
SilkySmooth's Avatar
SilkySmooth SilkySmooth is offline
Newbie :P
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2001
Location: In the PHP Engine :-)
Posts: 2,880 SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 32 m 23 sec
Reputation Power: 15
Try using the FTP functions?

http://php.net/ftp

HTH
__________________
---------------------
-- SilkySmooth --
---------------------
Proxy | Little Directory

Reply With Quote
  #3  
Old June 15th, 2003, 12:50 AM
HitByASquirrel HitByASquirrel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 HitByASquirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to HitByASquirrel Send a message via Yahoo to HitByASquirrel
well, it seems as if one needs to download each file individually, and I'm trying to find some way to downlaod an entire directory

Reply With Quote
  #4  
Old June 15th, 2003, 01:12 AM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 18
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
You have to download them file by file.
__________________
And you know I mean that.

Reply With Quote
  #5  
Old June 15th, 2003, 11:29 AM
HitByASquirrel HitByASquirrel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 HitByASquirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to HitByASquirrel Send a message via Yahoo to HitByASquirrel
in that case.... i think i'll make a function to do it, and post it on php.net

XD

Reply With Quote
  #6  
Old June 15th, 2003, 02:45 PM
HitByASquirrel HitByASquirrel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 HitByASquirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to HitByASquirrel Send a message via Yahoo to HitByASquirrel
Talking

PHP Code:
<?
/****************************************************************************
This code v1.0 is Copyright 2003 by Jon Bohren and Waveforme Backend Technologies
[email]jon@waveforme.com[/email]

This function, ftp_dget(), willl download a directory and all it's contents.
You can choose to download sub directories or not by passing TRUE or FALSE
into $subd.

Feel free to use or edit this code, but please keep the copyright. Thanks!

Enjoy.
*****************************************************************************/


function ftp_dget($conn_id$dir_name_local$dir_name_server$subd$mode) {
    
//get file list for directory to be downloaded    
    
$ls_dir ftp_rawlist($conn_id$dir_name_server);
    
    
//create local directory
    
if(!file_exists($dir_name_local))
        
$new_dir mkdir($dir_name_local0755);
    
$curr_dir chdir($dir_name_local);
    
    
//get rid of sub directories in file array if $subd is FALSE
    
if(!$subd) {
        
$s 0;
        for(
$i 0$i sizeof($ls_dir); $i++) {
            if(
$ls_dir[$i][0] != 'd') {
                
$ls_wsd[$s] = $ls_dir[$i];
                
$s++;
            }
        }
        
$ls_dir $ls_wsd;
    }
    
    
//download all files in the current directory, recursively call ftrp_dget() to downlaod sub-directories
    
for($i 0$i sizeof($ls_dir); $i++) {
        
$curr_f_name substr($ls_dir[$i], 55); //get actual file name
        
        
if($subd && ($ls_dir[$i][0] == 'd')) {
            
$dir_dl ftp_dget($conn_id$curr_f_name$dir_name_server."/".$curr_f_name$subd$mode)or die("Couldn't download '".$curr_f_name."' via FTP"); //recursively call ftp_dget
        
} else {
            
$file_dl ftp_get($conn_id$curr_f_name$dir_name_server."/".$curr_f_name$mode)or die("Couldn't download '".$curr_f_name."' via FTP"); //call ftp_get to downlaod the files in the current dir
        
}
        
        if(!(
$file_dl || $dir_dl))
            return 
FALSE;
    }
    
    
//return to previous directory
    
chdir("..");
    
    return 
TRUE;
}

$conn_id ftp_connect($ftp_host) or die("Couldn't connect to '".$ftp_host."'");
ftp_login($conn_id$ftp_user$ftp_pass) or die("Couldn't connect to the FTP server as '".$ftp_user."'");
        
ftp_dget($conn_id$local_dir$remote_dir$downlaod_sub_directories$mode);        

?>

Last edited by HitByASquirrel : June 15th, 2003 at 03:46 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > FTP and PHP....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT