PHP使用PHP无需使用API即可远程删除Dropbox上的文件 [英] PHP Remotely delete files on Dropbox using PHP without using an API
本文介绍了PHP使用PHP无需使用API即可远程删除Dropbox上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面的代码将文件上传到Dropbox。现在,我想修改以下代码,以删除特定文件夹中保管箱中的某些文件夹/图像。
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 />';
?>
如果不使用API(只是为了尝试新事物),我可以删除某些图片吗?
Without using an API(just for the sake of trying new things) could I delete certain pictures on my 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 />';
?>
没有错误和提示发生
推荐答案
您有一个多余的逗号,并且加了// //。也许这可以使它工作:
You have an extra comma and double //. Maybe this might make it work:
$dropbox_link->delete($dir.$dropbox_folder);
这篇关于PHP使用PHP无需使用API即可远程删除Dropbox上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文