Ruzzas Posted July 4, 2010 Share Posted July 4, 2010 I've got two functions. One which lists the folders/files in a folder (remotely) One which downloads all them (recursively) I need you guys to help me make: The downloader (mkdir) folders if they arn't already on the local drive, and to keep checking if there's a folder, If so check inside and make sure it empty, else add the files from that to the download list. The remote lister could probably be rewritten a little cleaner. But I'm going to leave it up to you guys. I'm confused on doing this and would appreciate it if you could give a few minutes to help me. Code: function RemoteListDirectory($Directory, $Array = array(), $First = True){ global $Server; global $Connection; if($Connection){ if($First){ ftp_chdir($Connection, $Directory); } if(ftp_size($Connection, $Directory) != -1){ if($First){ return False; } $Array[] = $Directory; return $Array; }else{ $Contents = ftp_nlist($Connection, $Directory); if(!count($Contents)){ $Array[] = $Directory; return $Array; } foreach($Contents as $File){ $Array[] = RemoteListDirectory($File, $Array, False); } if($Array = Strip($Server['RDirectory'], ".", $Array)){ return $Array; }else{ return False; } } }else{ return False; } } function Download($Array = array(), $Recursive = False){ global $Connection; if($Connection){ for($I=0;$I<count($Array);$I++){ if($Array[$I] != ""){ if($ftp_size($Connection, $Array[$I] == -1)){ $Array = array_merge($Array, Download($Array[$I], True)); }else{ ftp_get($Connection,$Array[$I],$Array[$I],FTP_BINARY); } if($Recursive){ $Directory = ftp_pwd($Connection); $Array[] = "$Directory/$Array[$I]"; }else{ $Array[] = $Array[$I]; } } } }else{ return False; } return $Array; } Quote Link to comment Share on other sites More sharing options...
Ruzzas Posted July 4, 2010 Author Share Posted July 4, 2010 its not that hard, help me out... Quote Link to comment Share on other sites More sharing options...
Ruzzas Posted July 10, 2010 Author Share Posted July 10, 2010 bump Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.