Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Sciaganie i wyswietlanie plików poza public_html
sanchoo
post
Post #1





Grupa: Zarejestrowani
Postów: 161
Pomógł: 1
Dołączył: 11.02.2007
Skąd: Kraków

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


Mam uplad nas stronie. Pliki sa zapisywane po za public_html.
Znalazlem i przerobilem skrypt do pobierania:
  1. <?php
  2. public function download($filename)
  3. {
  4. if(ini_get('zlib.output_compression'))
  5.  ini_set('zlib.output_compression', 'Off');
  6.  
  7. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  8.  
  9. if( $filename == "" ) 
  10. {
  11. }
  12. elseif ( ! file_exists( $filename ) ) 
  13. {
  14.  
  15. };
  16.  
  17. switch( $file_extension )
  18. {
  19. case "pdf": $ctype="application/pdf"; break;
  20. case "exe": $ctype="application/octet-stream"; break;
  21. case "zip": $ctype="application/zip"; break;
  22. case "doc": $ctype="application/msword"; break;
  23. case "xls": $ctype="application/vnd.ms-excel"; break;
  24. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  25. case "gif": $ctype="image/gif"; break;
  26. case "png": $ctype="image/png"; break;
  27. case "jpeg":
  28. case "jpg": $ctype="image/jpg"; break;
  29.  
  30. default: $ctype="application/force-download";
  31. }
  32.  
  33. header("Pragma: public"); // required
  34. header("Expires: 0");
  35. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  36. header("Cache-Control: private",false); // required for certain browsers 
  37. header("Content-Type: $ctype");
  38. //  change, added quotes to allow spaces in filenames, by Rajkumar Singh
  39. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
  40. header("Content-Transfer-Encoding: binary");
  41. header("Content-Length: ".filesize($filename));
  42. readfile("$filename");
  43.  
  44.  
  45. }
  46. ?>


niby pobiera... ale :/
plik tekstowy np. wyglada tak:
  1. <b>Warning</b>: readfile(/home/XXX/demo-modal-message-3.inc) [<a href='function.readfile'>function.readfile</a>]: failed to open stream: Permission denied in <b>/home/inf_sto_1/sanchoo/public_html/services/class_model.php</b> on line <b>859</b><br />
  2. MODELincinczipdllmp3iniexetxtmp3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stri


wogole czy jest to mozliwe??
Potrzebuje aby plik sie sciagal a graficzny byl wyswietlany.
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 Aktualny czas: 19.08.2025 - 16:22