Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] problemy z download
swiety
post
Post #1





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 23.03.2005

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


hej, mam nastepujacy problem, chce udostepnic pliki do sciagania, uzywam do tego celu funkcji readfile(), wszystko niby gra, pliki sie sciagaja, ale np jpg, albo exe po sciagnieciu nie daja sie otworzyc, kiedy sciagam plik pdf to wszystko jest ok, tutaj moj cod:
  1. <?php
  2. $id=$_REQUEST['ID'];
  3.  
  4. $database->setQuery("SELECT file_path, file_name FROM #__tryouts_files WHERE id = $id");
  5. $file = $database->loadObjectList();
  6. header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7. header("Content-type: application/octet-stream");
  8. header('Content-Length: ' . filesize($file[0]->file_name));
  9. header('Content-Disposition: attachment; filename="' . basename($file[0]->file_name) . '"');
  10. readfile($file[0]->file_path);
  11. exit();
  12. //include("down_file.php");
  13. ?>

z gory dzieki za kazda pomoc, (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
swiety
post
Post #2





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 23.03.2005

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


niestety dalej to samo, moj kod od poczatku do header():
  1. <?php
  2. defined( '_VALID_MOS' ) or die( 'Direct Access to this script is not allowed');
  3.  
  4. $image_path = $GLOBALS[mosConfig_live_site]."/templates/".$GLOBALS[cur_template]."/images/";
  5.  
  6. $mainframe->setPageTitle ("Tryouts");
  7.  
  8.  $query = 'SELECT * FROM #__tryouts_cat WHERE published="1" ORDER BY id';
  9.  $database->setQuery( $query );
  10.  $cat = $database->loadObjectList();
  11.  
  12.  
  13. if(isset($_REQUEST['ID'])&&($_REQUEST['download']==1)) {
  14.  
  15. $id=$_REQUEST['ID'];
  16.  
  17. $database->setQuery("SELECT file_path, file_name FROM #__tryouts_files WHERE id = $id");
  18. $file = $database->loadObjectList();
  19. header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  20. header("Content-type: application/octet-stream");
  21. header('Content-Length: ' . filesize($file[0]->file_name));
  22. header('Content-Disposition: attachment; filename="' . basename($file[0]->file_name) . '"');
  23. readfile($file[0]->file_path);
  24. exit();
  25.  
  26. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 9.10.2025 - 23:37