יש לי קישור הורדה מאתר אחר לדוגמא(
http://google.co.il/500mb.rar)
אני מעוניין לעשות סוג של העברה,
גולש מסויים יכנס לכתובת אתר שלי.
xxx.xxx.xxx.xxx/file.php
אני רוצה שיקפוץ לו חלון הורדה של הקובץ שהבאתי למעלה,(500mb.rar)
אז שיועבר דרכי,
אז עשיתי ככה:
PHP קוד:
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header("Content-Type: ".$url);
header("Content-Disposition: attachment; filename=".$url);
header('Content-Length: ' . size($r));
ob_clean();
flush();
readfile($n);
**
function size()
PHP קוד:
$file = $n;
$ch = curl_init($file);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if(preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$contentLength = (int)$matches[1];
}
return $contentLength;
הוא מוריד הכל טוב ויפה,
אבל הוא לא מראה כמה גודל הקובץ, כמה נותר וכ'ו(בדפדפן)..