|
Posted by kachorro on 09/15/05 14:08
Hi all!
Ive been working in jpg downloader for my site.
The user chooses a pic and if he is a valid user, he is able to download the
pic.
My code is like that..
<?
ob_start()
?>
if (picChoose()){
if (validUser()){
header (Location: downloader.php?img=1.jpg)
}
}else{
echo from to select the pic
}
<?
ob_flush()
?>
Calling the code in upper way the img is downloaded and downloaded ok,
but, if i write the code like below
if (validUser()){
$fd=null, $buffer=null;
if ($fd = fopen ($ruta, "r")) {
$fsize = filesize($ruta);
$infoRuta = pathinfo($ruta);
$ext = strtolower($infoRuta["extension"]);
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".
$infoRuta["basename"]."\"");
header("Content-length: $fsize");
header("Cache-control: private");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
}
}
fclose ($fd);
exit;
}
it does not work properly
the source image and the downloaded one are different
first bites form the source => ff d8 ff e0 00
first bites from the downloade one => 0a ff d8 ff e0 00 it adds 0a
does anyone know why ???
Thank in advance
Kaxorro
Navigation:
[Reply to this message]
|