Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> header() - wielokrotny download
redman2
post 1.03.2006, 10:31:12
Post #1





Grupa: Zarejestrowani
Postów: 104
Pomógł: 3
Dołączył: 13.10.2004

Ostrzeżenie: (0%)
-----


Czy spotkal sie ktos z problemem wysylania naglowkow w petli?

W moim przypadku chodzi o download kilku plikow z bazy MySQL.

Jezeli zrobie to w petli, dziala tylko raz. Dla jednego naglowka. Potem wychodzi calkowicie ze skryptu.

Jak ten problem rozwiazac?

  1. <?php
  2.  
  3.  
  4.  
  5. foreach ($keyarray as $key => $value) {
  6.  
  7. if (strstr($key,'item_number')!=FALSE) {
  8.  
  9.  
  10.  
  11. $dbQuery = "SELECT * FROM micropayments WHERE id = '$value' ";
  12.  
  13. $result = mysql_query($dbQuery) or die("Couldn't get file list");
  14.  
  15. if(mysql_num_rows($result) == 1) {
  16.  
  17. while ($row = mysql_fetch_array($result)) {
  18.  
  19. $fileContent = $row['pdf'];
  20. $fileTitle = $row['title'].".pdf";
  21.  
  22. if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) {
  23.  // IE Bug in download name workaround
  24.  ini_set( 'zlib.output_compression','Off' );
  25.  } 
  26.  
  27.  header("Pragma: public");
  28.  header("Expires: 0");
  29.  header("Cache-Control: public");
  30.  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  31.  header("Content-type: application/pdf");
  32.  header('Content-Disposition: attachment; filename="' . $fileTitle . '"');
  33.  header("Content-Transfer-Encoding: binary");
  34.  
  35. echo $fileContent;
  36. }
  37. } else echo "Record doesn't exist.";
  38.  
  39. }
  40.  
  41. }
  42.  
  43. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 06:26