0

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='[email protected]';  //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='[email protected]';  //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

2
  • Check if the method $dropbox_link->delete had capability to delete folders. Coz the parameters you are passing looks like a whole folder and not a file. Commented Oct 20, 2013 at 23:05
  • "Without an API" - impossible. You'd at least utilize the API Dropbox offers to access the files. Commented Oct 20, 2013 at 23:09

1 Answer 1

0

You have an extra comma and double //. Maybe this might make it work:

$dropbox_link->delete($dir.$dropbox_folder);  
Sign up to request clarification or add additional context in comments.

3 Comments

PHP Warning: scandir()
You can remove that line: $files = scandir($dir);
what does $siteroot = $folder_output; output?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.