Server error! Mail admin at admin@{$_SERVER['HTTP_HOST']}";
header("Location: ../fileManager.php");
return;
}
$found = false;
while (!feof($fd))
{
$line = trim(fgets($fd));
$arr = explode(";", $line);
if ( count($arr) == 4 )
{
if ( $id === $arr[0] )
{
$found = true;
$path = $arr[2];
$name = $arr[1];
break;
}
}
}
//var_dump($found);
//var_dump($path . $id);
//var_dump(!file_exists($path . $id));
if ( !$found || !file_exists($path . $id) )
{
$_SESSION["communicates"]["fileError"] = "No file with given id!";
return;
}
$fd = fopen($path . $id, "r");
$size = filesize($path . $id);
//$contents = fread($fd, $size);
fclose($fd);
header("Content-Type: application/octet-stream");
header("Content-Length: $size;");
header('Content-Disposition: attachment; filename="'.$name.'"');
echo file_get_contents($path . $id);
//echo $contents;
}
if ( !empty($_GET['fileid']) )
send($_GET['fileid']);
else
{
$_SESSION["communicates"]["fileError"] = "No file id given!";
header("Location: ../fileManager.php");
}
?>