Autor | Zpráva | ||
---|---|---|---|
Fisak Profil |
#1 · Zasláno: 2. 6. 2012, 11:23:20
Dobrý den. Naskytl se mi takový problém. Když chci stáhnout txt soubor tak mi můj skript (můj v tom smyslu že je u mě na webu) stáhne txt soubor ale jsou tam jen kody tedy tolik znaků kodu kolik jsem napsal do textového souboru znaků... takže např. napíšu do txt souboru "ahoja" a tento skript stáhne soubor s obsahem "<scri"
function download_file($file) { if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) { ini_set( 'zlib.output_compression','Off' ); } header ('Content-Disposition: attachment; filename="'.basename($file).'"'); header ('Expires: '.gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y"))).' GMT'); header ('Accept-Ranges: bytes'); header ('Cache-control: no-cache, must-revalidate'); header ('Pragma: private'); $size = filesize($file); if(isset($_SERVER['HTTP_RANGE'])) { list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']); str_replace($range, "-", $range); $size2=$size-1; $new_length=$size2-$range; header("HTTP/1.1 206 Partial Content"); header("Content-Length: $new_length"); header("Content-Range: bytes $range$size2/$size"); } else { $size2=$size-1; header("Content-Range: bytes 0-$size2/$size"); header("Content-Length: ".$size); } if ($file = fopen($file, 'rb')) { while(!feof($file) and (connection_status()==0)) { print(fread($file, 1024*8)); flush(); } $status = (connection_status()==0); fclose($file); } return($status); } |
||
greeny Profil |
#2 · Zasláno: 2. 6. 2012, 19:53:55
nevím, kde je chyba ale minimálně doporučuju radši
$string=file_get_contents($file) a echo $string;
|
||
Časová prodleva: 12 let
|
0