-2

I need to download a couple of images directly from my Website using Php and JS, the user will select some of them by clicking into a checkbox and them click in a button named Download that will launch the action. The html is showed below:

<div class="item-image">
  <input class="caixaSelecao" type="checkbox" name="image[1]" >
  <img id="1" class="thumbnail" src="<?= include_url('Im.jpg');?>" />
</div>
  • First you can do this by zipping all the files. Or using Javascript. – Jose Marques Apr 21 '17 at 22:54
  • `include_url()` what does that do? That isn't a core php function, so if you're trying to run a JS method; it won't work. The question is way too unclear, and if you've no code, then this too broad since it looks like you're asking us how to do it all. – Funk Forty Niner Apr 21 '17 at 23:22

1 Answers1

0

If you want to use the method of zip the images, use this example to begin

Example from Download multiple files as a zip-file using php

zip:

$files = array('readme.txt', 'test.html', 'image.gif');
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($files as $file) {
  $zip->addFile($file);
}
$zip->close();

and to stream it:

header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);

Using Jscript, use this example to begin.

Exemple from How can I let a user download multiple files when a button is clicked?

HTML:

<a href="#" class="yourlink">Download</a>

JS:

$('a.yourlink').click(function(e) {
    e.preventDefault();
    window.open('mysite.com/file1');
    window.open('mysite.com/file2');
    window.open('mysite.com/file3');
});

Any doubt is just asking, that I will try to answer your doubts

Jose Marques
  • 748
  • 1
  • 6
  • 22