Hi,
I'm trying to download an image with the dropbox SDK for PHP, in the future I'll hopefully use Delta to update.
I'm having trouble saving the image as I'm not actually sure where the image is being stored in PHP. Currently I get a .jpeg file but it is un-openable, I presume it's actually text or something.
The browser does show the image meta so I know it's successfully contacting the dropbox servers. The contents of /Dropbox-SDK are unmodified.
Here is my current code:
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
require_once "Dropbox-SDK/Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("Dropbox-SDK/Dropbox/config.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
$accessToken = "XXXXXXXX";
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
//getDelta($cursor = null, $pathPrefix = null );
//getFile($path = '/Scouts/Images/Glide1.jpeg', $outStream = $login, $rev = null );
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
$filename = 'Glide1.jpeg';
$input = '/Scouts/Images/'.$filename;
$output = '/var/www/vhosts/MY/DOMAIN/images/dropbox/'.$filename;
$f = fopen($filename, "w+b");
$fileImage = $dbxClient->getFile($input, $f);
fclose($f);
print_r ($fileImage);
if(file_put_contents($output, $fileImage)){echo '<hr/>File saved successfully!';}