title: How to download to the browser multiple pictures in php
body: <p>I'm getting some pictures paths via a webservice this way :</p>
  
  <pre><code> 0 =&gt; string '/home/41/38/58/96/photos/1.jpg' 
   1 =&gt; string '/home/41/38/58/96/photos/2.jpg'
   2 =&gt; string '/home/41/38/58/96/photos/3.jpg'
  </code></pre>
  
  <p>I'm trying to download them to the browser via a PHP script :</p>
  
  <pre><code>foreach($files as $index =&gt; $files){
          if($index !== 'debug'){
              $file_name = basename($file);
              $final_file = @fopen($file,"rb");
  
              header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
              header("Pragma: public");
              header("Content-Type: image/jpeg");
              header('Content-Description: File Transfer');
              header("Content-Disposition: attachment; filename=\"$file_name\"");
              header('Content-Transfer-Encoding: binary');
  
              header('Content-Length: '.filesize($file));
  
              print(@fread($final_file, filesize($file)));
              ob_flush();
              flush();
  
              @fclose($final_file);
          }
      }
  </code></pre>
  
  <p>The problem is that i'm getting just one picture even if my array contains the three links like you see. So what i'm doing wrong.</p>