עריכה:
הצלחתי לסדר שיוריד אבל הקבצים יוצאים פגומים.
זה הקוד:
PHP קוד:
<? ob_start(); ?>
<?php
function download_file($file)
{
$query = mysql_query("SELECT * FROM upload where id = '{$_GET['id']}'") or die("error");
$row = mysql_fetch_array($query);
$num = mysql_num_rows($query);
if($num == 0)
{
die(" לא קיימת הורדה התואמת לחפושך ") ;
}
$id = $row['id'];
$name = $row['name'];
$size = $row['size'];
$type = $row['type'];
// By maor
$filename = basename($file);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
$input = strtolower($_SERVER['QUERY_STRING']);
$no_good_extensions = array("php"."php1","php2","php3","php4");
$return = str_replace($no_good_extensions, "", $input);
if( $input != $return )
{
die( " סוג הקובץ שאתה מנסה להוריד לא מורשה ");
}
$file = $row['name'];
header ("Content-type: application/$type");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
}
download_file(date/$name);
?>
אם בא לכם לנסות אתם מוזמנים לבדוק:
http://elad.fire-serv.net/test.php
עריכה 2 :
הסתדרתי כבר תודה בכל מקרה.
תודה ל lalamen שעזר לי.