如何使用php将上传文件和文件夹/子文件夹设置为dropbox

时间:2016-10-19 23:26:38

标签: php dropbox

我使用dropphp将上传文件用于dropbox并且运行正常,但现在我想将文件和文件夹/子文件夹上传到dropbox,当文件夹/子文件夹和文件在dropbox路径位置中同名时...

我从here

找到了这段代码
// Set the timezone so filenames are correct
date_default_timezone_set('Europe/London');

// Backup all files in public_html apart from the gz
$siteroot = "/path/to/backup";

$dropbox_email='dropbox@email';  //Dropbox username
$dropbox_pass='pass';   // Dropbox password

include("DropboxUploader.php");

$uploader = new DropboxUploader($dropbox_email, $dropbox_pass);

function FolderToDropbox($dir, $dropbox_link){    
    $dropbox_folder = 'FolderInDropboxRoot/';
    $files = scandir($dir);
    foreach($files as $item){
        if($item != '.' && $item != '..'){
            if(is_dir($dir.'/'.$item))     FolderToDropbox($dir.'/'.$item,$dropbox_link);
            else if(is_file($dir.'/'.$item)) {
                $clean_dir = str_replace("/path/to/backup", "", $dir);
                        $dropbox_link->upload($dir.'/'.$item,$dropbox_folder.$clean_dir.'/');  
            } 
        }
    }
    }

    FolderToDropbox($siteroot,$uploader);

但不起作用,也许同样改变新的api

  

dropboxuploader.php

如何为dropphp或使用Dropbox SDK修改代码?

谢谢

0 个答案:

没有答案