Here is the TK:
There is a list of links to files, getting the link for one cycle foreach cycle. I need to write these files to a zip archive and suggest the user to download it.
how to do it? With all the links pointing to another server.
that's what happened with me

 $zip = new ZipArchive; $zip->open('/user/'.$id.'.zip', ZipArchive::CREATE); foreach ($response->data as $item) { $zip->addFile("$item->images->standard_resolution->url"); echo $item->images->standard_resolution->url; echo '<br>'; $zip->close(); 

But no file is created in the users folder :(

    1 answer 1

    Nothing is created in the users folder because you create an archive in the user folder.

    You need to add the file to the archive and you add links to it. You must first download the file. You can somehow like this:

     $img = '/my/folder/someimage.jpg'; file_put_contents($img, file_get_contents($item->images->standard_resolution->url)); 

    You can use curl if you like it more.

    You need to add a file to the archive only after you download it.

     $zip->addFile($img);