Saving images called directly from ODK database

Hi,

I am pulling the images stored in ODK database in my dashboard via direct URL:

http://xxx.something.com/view/binaryData?blobKey=reg_form[%40version%3Dnull+and+%40uiVersion%3Dnull]%2Fregistrition_form4[%40key%3Duuid%3Axxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx]%2FSection_3%3ASection_4_1_newphoto

These images open perfectly fine in the browser, however they are still residing in the ODK database/table and being called from there. I need to save these images automatically as some jpeg file in my dashboard folder. How would I go about doing that?

Thanks,
Saad

OK I got it. Sharing for everyone's help:

<?php
$url = 'IMAGE_URL_FROM_ODK_DB';
$img = 'img.jpg';
file_put_contents($img, file_get_contents($url));
?>

Make sure to allow permissions for img.jpg file on filesystem.

Cheers!

2 Likes