We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
knalpiap
8 years agoHelpful | Level 5
PHP - Show thumbnail
Hi peepz, I'm running a PHP project for which I read a specific Dropbox directoty using 'list_folder'. Five files (JPG), matching certain criteria are selected from all returned files. So far, so ...
- 8 years ago
Wow!! I've managed to work it out :)
I've read the following post again https://www.dropboxforum.com/t5/API-support/API-v2-Simple-image-gallery-on-my-website-using-dropbox/td-p/169202After this, all I additionally changed is
echo $result;
to
$data = base64_encode( $result ); echo '<img src="data:image/jpg;charset=utf8;base64,'.$data.' />';
and now it works!! Thank you so much!
Best,
Knal
knalpiap
Helpful | Level 5
Hi Greg,
Thanks a lot for pointing me in the right direction!
I've changed the code based on what I understood from your input:
<?PHP $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://content.dropboxapi.com/2/files/get_thumbnail"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $headers = array(); $headers[] = "Authorization: Bearer XXX_SECRET_CODE_XXX"; $headers[] = "Content-Type:"; $headers[] = 'Dropbox-API-Arg: {"path":"/DropsyncFiles/2017.09.01_22.36.01/20170901223632654.jpg","format":{".tag":"jpeg"},"size":{".tag":"w1024h768"}}'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch); //echo imagecreatefromstring( $result ); <-- Returns 'Resource id #2' in the browser echo $result; ?>
The current output is complete jibberish like follows:
ÿØÿàJFIFÿâDICC_PROFILE4mntrRGB XYZ Þ+8acspöÖÓ- descüybkptxwtptŒcprt rXYZ¸gXYZÌbXYZàrTRCô@gTRCô@bTRCô@descsRGB IEC61966-2-1 black scaledXYZ 3¤XYZ öÖÓ-textDropbox, Inc.XYZ o¢8õXYZ b™·…ÚXYZ $ „¶ÏcurvÅÌb“kö@Q4!ñ)2;’FQv]íkpz‰²š|¬i¿~ÓÁé7ÿÿÿÛC %# , #&')*)-0-(0%()(ÿÛC (((((((((((((((((((((((((((((((((((((((((((((((((((ÿÀà€"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ?ùÁIèiØëH£¹ÇáÔúö®C±7Ô@:ÒJZP2;ÒZħãšw§/¿SíI”•„ 8§(ã¯N´¸â”Th7…>?¼=&:Զɺ@=Çó© Èßï1÷¦Ž¼TÌ “íI°z÷¤ €jYäS“Óˆ4У’EJT0;_óé@Y•ñ€~´cßó§m眿.csž¿•(O§ãONs€E:„ \g¿#Ú€½y©(¢Ã°Í¾ÿêj}ÂÚÆ98¤úÓÆÀàQBbh`zP^ <€zÐQpåJ úS€Çnih¸(÷Ž:S@>§KE(мž´mÁõ§Q@$&:ã½-P0¤õÇzZ(Æ@ tâ–Š(¢Š(£PEPEPœPG¹¥¢€ŒR0zÓ¨ w§NÔm8ì u ‘mãÚ“¥›zàÓL›ãÞ’¤aüñL c#¥4ÃÔJkô4ïÆšãå4Кº)H:ÒGO¶i©Ðçl¶1¶£ñSÛu÷#Ö¢#$sRÛžÝ+9lTw-Žÿ…7ƒŸPqO8éH}ˆ÷â²¹ºÐf ¡à`SñþsMÆ:tÍ"®F}(©äži»@Zi¢6“§¯±¤§qlã¶i¸Å;¥'NûRCLAžýèçg9ýhö¦˜ÛÉéIj“ÜqøS(Ä?Nµ8äTH9Õ§|:à`r…J·ëÞº3áÅŬ†îxî±…þb¿4g¨ïúW4ñT¡£‘¢¤Ï8Û‚ÙõýA"Œg©VÐÐ&µ¼ŠÚvY¡¸Ï“:tcéÏC팊ÈòÝT³FÁ7 ùñ[
... but then a lot longer.
I imagine this is the actual image data, but now I can't output it as an image. Also, I've read your endpoint download link again (I did before posting) but I can't figure out what this means for my code.
My apologies, I am not very good at coding as you can see :)
Thanks,
Knal
knalpiap
8 years agoHelpful | Level 5
Wow!! I've managed to work it out :)
I've read the following post again https://www.dropboxforum.com/t5/API-support/API-v2-Simple-image-gallery-on-my-website-using-dropbox/td-p/169202
After this, all I additionally changed is
echo $result;
to
$data = base64_encode( $result ); echo '<img src="data:image/jpg;charset=utf8;base64,'.$data.' />';
and now it works!! Thank you so much!
Best,
Knal
- lrduques6 years agoHelpful | Level 6
Hi!!
I am having the same issue here. I tried to read to documentation at the link below but I received a message saying: access denied!
Can you help me out pleeease?
Thank you in advance.
- Pavlitto6 years agoExplorer | Level 4
Your answer have a little problem,
$data = base64_encode( $result ); echo '<img src="data:image/jpg;charset=utf8;base64,'.$data.' />';
after the $data at the end you should ad ( " ) before closing so this should look like this
$data = base64_encode( $result ); echo '<img src="data:image/jpg;charset=utf8;base64,'.$data.' " />';
- Inderjeetdev10 months agoHelpful | Level 5
It worked:
$data = base64_encode( $response ); echo '<img src="data:image/jpg;base64,'.$data.'" />';
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 8 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!