I'm looking for a way to save images stored in a MySQL database on a different server to a directory on the server I'm currently working with. I'm retrieving JSON data, and each entry displays a url that links directly to the image stored in the database. This is what I'm doing currently, with no success.
<?php
$url = 'https://secure.example.com/app/api?accountid=000&apikey=000&action=getview&format=json&viewid=0000&tableid=0000';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$imageList = json_decode($response,true);
$x = 1;
foreach ($imageList as $imageItem) {
$img = $imageItem['face_image'];
echo "<img src='" . $img . "' width='150' height='200'/>"; //THIS WORKS, DISPLAYS IMAGES
$dest_dir = "/uploads/"; //THIS DIRECTORY IS 777 CURRENTLY
$src_file = $img;
file_put_contents($dest_dir.$x.".jpg", $src_file);
$x++;
}?>