问题
I have the code below to upload files to Dropbox. Now I'd like to modify the code below to delete certain folders / images on dropbox in a particular folder.
<?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 />';
?>
Without using an API(just for the sake of trying new things) could I delete certain pictures on my Dropbox.
I tried this code:
<?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 />';
?>
No errors and ntohing happens
回答1:
You have an extra comma and double //. Maybe this might make it work:
$dropbox_link->delete($dir.$dropbox_folder);
来源:https://stackoverflow.com/questions/19483881/php-remotely-delete-files-on-dropbox-using-php-without-using-an-api