Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Ściąganie na dysk swf , flv
Woijtek338
post
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 0
Dołączył: 5.06.2011

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


Witam! Napisałem taki oto kodzik
  1. $fullPath = '../slajdy/'.$_POST['hid'];
  2. //$fullPath = '../slajdy/00055e6998210f4718899a4300c80f30.jpg';
  3. if ($fd = fopen ($fullPath, "r")) {
  4. $fsize = filesize($fullPath);
  5. $path_parts = pathinfo($fullPath);
  6. $ext = strtolower($path_parts["extension"]);
  7. switch ($ext) {
  8. case "jpg":
  9. header("Content-type: image/jpg");
  10. header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\"");
  11. break;
  12. case 'png':
  13. header("Content-Type: image/png");
  14. break;
  15. case 'gif':
  16. header("Content-Type: image/gif");
  17. break;
  18. case 'swf':
  19. header("Content-Type: application/x-shockwave-flash");
  20. break;
  21. case 'flv':
  22. header('Content-Type: video/x-flv');
  23. break;
  24.  
  25. default;
  26. header("Pragma: public");
  27. header("Expires: 0");
  28. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  29. header("Content-type: application/octet-stream");
  30. header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
  31. }
  32. header("Content-length: $fsize");
  33. header("Cache-control: private");
  34. while(!feof($fd)) {
  35. $buffer = fread($fd, 2048);
  36. echo $buffer;
  37. }
  38. }
  39. fclose ($fd);


Jak widzicie, ma on za zadanie ściągać pliki na dysk po kliknięciu jakiegoś tam przycisku. Wszystko jest ok z plikami typu jpg, gif , natomiast przy próbie ściągniecia flv lub swf zamiast ściągać film, to ściąga skrypt php w którym umieszczony jest w/w kod .
Dlaczego ?
Go to the top of the page
+Quote Post

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: 20.08.2025 - 19:16