It's not quite working, and I think the problem is the path to write the contents to. Maybe you can help me out:
$i = 1;
while ($row = mysqli_fetch_assoc($result)) {
$thumb = file_get_contents($row['small_thumb']);
$name = 'sml-' . $row['prodid'];
file_put_contents("/images/thumbs/{$name}.jpg", $thumb);
$i++;
}
echo "$i thumbs saved";
The goal is to open the file that will be something like www.remote.com/images/111.jpg and save it to www.local.com/images/thumbs/sml-111.jpg
I tried using a full path http://www.local.com... in the file_put_contents function but got an http error saying that http wrapper does not support writable connections, and through searching online, some suggest using realpath(), or something similar to do with the path of where I'm saving the file. What I don't understand about realpath() is how I specify the path of the directory I'm not in.
Does the script I'm using this code in have to be in the same folder as where I want to save the images?
Is everything else right, aside from specifying where I want the images saved?
Thanks for your help!