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; } Link to comment https://forums.phpfreaks.com/topic/206681-functions-folders-and-files-help-needed/ 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... Link to comment https://forums.phpfreaks.com/topic/206681-functions-folders-and-files-help-needed/#findComment-1080996 Share on other sites More sharing options...
Ruzzas Posted July 10, 2010 Author Share Posted July 10, 2010 bump Link to comment https://forums.phpfreaks.com/topic/206681-functions-folders-and-files-help-needed/#findComment-1084022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.