Jump to content

FTP_GET Folders, Attempted failed, Need help here


Ruzzas

Recommended Posts

I've got two functions which one downloads files and zips the one that doesen't end with .dua and .txt

 

But I want to download folders and their contents and means if a folder has a folder which has a folder and its got content, I wan't it to download the whole lot.

 

Anyways heres the two functions:

 

function Download($Array){
    global $Connection;
    if($Connection){
        for($i=0;$i<count($Array);$i++){
            if($ArrayExplode = (explode(".", $Array[$i]))){
                if($ArrayExplode[1] != "dua" & $ArrayExplode[1] != "txt"){
                    Zip($Array[$i]);
                }
            }
            if($Array[$i] != ""){
                if(FolderContents($Array[$i]) == "false"){
                    ftp_get($Connection,$Array[$i],$Array[$i],FTP_BINARY);
                }else{
                    DownloadFolders($Array[$i]);
                }
            }
        }
        return true;
    }else{
        return false;
    }
}

function DownloadFolders($Folder){
    global $Connection;
    if($Connection){
        if($ArrayExplode = (explode(".", $Folder))){
            if($ArrayExplode[0] != "" & $ArrayExplode[1] == ""){
                $FolderContents = FolderContents($Folder);
                for($e=0;$e<count($FolderContents);$e++){
                    if(mkdir($Folder,0777,true)){
                        if(ftp_chdir($Connection,$Folder)){
                            ftp_get($Connection,$FolderContents[$e],$FolderContents[$e],FTP_BINARY);
                        }
                    }
                }
                @ftp_cdup($Connection);
            }
        }
    }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.