PHP使用PHP远程删除Dropbox上的文件而不使用API

时间:2013-10-20 22:59:55

标签: php dropbox

我有以下代码将文件上传到Dropbox。现在,我想修改下面的代码,删除特定文件夹中Dropbox上的某些文件夹/图像。

<?php
$siteroot = $folder_output; 

$dropbox_email='xxx@xxxxx.com';  //Dropbox username
$dropbox_pass='xxxxxxxxxxxx';   // Dropbox password

include("DropboxUploader.php");

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

function FolderToDropbox($dir, $dropbox_link){
    global $foldername;    
    $dropbox_folder = 'Public/';
    $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("temp_images/".$foldername."/output/", "", $dir);
                $dropbox_link->upload($dir.'/'.$item,$dropbox_folder.$clean_dir.'/');  
            } 
        }
    }
}

FolderToDropbox($siteroot,$uploader);

echo 'Copying to Cloud - Success!<br />';


?>

如果不使用API​​(只是为了尝试新事物),我可以删除Dropbox上的某些图片。

我试过这段代码:

<?php
ini_set('display_errors',1); error_reporting(E_ALL);

$siteroot = $folder_output; 

$dropbox_email='xxxx@xxxxxxx.com';  //Dropbox username
$dropbox_pass='xxxxxxxxxxxxxxxxx';   // Dropbox password

include("DropboxUploader.php");

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

function FolderToDropbox($dir, $dropbox_link){
    global $foldername;    
    $dropbox_folder = 'Public/';
    $files = scandir($dir);
    $dropbox_link->delete($dir.,$dropbox_folder.'/');  
            } 
        }
    }
}
 FolderToDropbox($siteroot,$uploader);
echo 'Copying to Cloud - Success!<br />';

?>

没有错误和发生错误

1 个答案:

答案 0 :(得分:0)

你有一个额外的逗号和双//。也许这可能会起作用:

$dropbox_link->delete($dir.$dropbox_folder);