问题
I made a script where I download the images from a dropbox folder to my computer using PHP. What I try to do now is to download thumbnail of the images instead of the whole image. For this I use the: GetThumbNail method from the Dropbox API. Here is part of the code:
// download the files
$f = fopen($img_name, "w+b");
$fileMetadata = $dbxClient->getThumbnail($path, 'jpeg','xl');
fclose($f);
When I run this the images I get are 0 size and they have no content. Any ideas what I am missing? Thanks D.
EDITED
$f = fopen($img_name, 'w+b');
$thumbnailData = $dbxClient->getThumbnail($path, 'jpeg', 'xl');
fwrite($f, $thumbnailData);
fclose($f);
回答1:
You're opening and closing $f
without ever writing anything into it.
getThumbnail returns an array with two elements: the metadata for the file and the thumbnail data.
So I think you'll want something like this:
$f = fopen($img_name, 'w+b');
list($fileMetadata, $thumbnailData) = $dbxClient->getThumbnail($path, 'jpeg', 'xl');
fwrite($f, $thumbnailData);
fclose($f);
来源:https://stackoverflow.com/questions/27344561/download-a-thubnails-of-an-image-using-dropbox-api-for-php