Topic: Page of return of files php

Hello. There is a direct reference on a file (mp3) but at its discovery simply plays back a file. I found here such script

$filename = $ _GET [' filename '];
$name = $ _GET [' name '];
Template Name: downloa
//it is necessary for Internet Explorer, differently Content-Disposition it is ignored
if (ini_get (' zlib.output_compression '))
ini_set (' zlib.output_compression ', ' Off ');
$file_extension = strtolower (substr (strrchr ($filename, "."), 1));
if ($file_extension == "php") {echo "php a file, it it is impossible to download It!"; exit;}
switch ($file_extension)
case "mp3": $ctype = "audio/mp3"; break;
default: $ctype = "application/force-download";
header (' Content-Description: File Transfer ');
header (' Content-Type: application/octet-stream ');
header (' Content-Disposition: attachment; filename = '. basename ($filename));
header (' Content-Transfer-Encoding: binary ');
header (' Expires: 0 ');
header (' Cache-Control: must-revalidate ');
header (' Pragma: public ');
header (' Content-Length: '. filesize ($filename));
readfile ($file);

from the PC swings normally. But here from phone downloads only through yandex the browser. To Google chrome writes it was not possible to download a file because of an unknown error and in standardly browser downloads but an empty file with a size 0.0.


Re: Page of return of files php

And you understand that this script it is possible to download almost any file (except *.php) from the server to which Web server process has access? Well and $ctype it is not used, it is possible to delete all switch. And in essence, it can helps?


Re: Page of return of files php

The strange any code. On idea, it at all should not to work - the variable $file is not defined.