This question already has an answer here:
- Make multiple files to force-download 4 answers
I have a problem. I want to download multiple images form urls to visitor device. I dont need to zip the files. Just download one by one
This is my code :
$files = array(
'https://example.com/image.jpg',
'https://example.com/image2.jpg',
'https://example.com/image3.jpg'
);
foreach($files as $file)
{
$filename = 'images.jpg';
function forceDownload($filename, $type = "image/jpeg") {
header('Content-Type: '.$type.'; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$filename.'"');
}
forceDownload($filename, "image/jpeg");
echo file_get_contents($file);
}
Thanks
</div>