Stream Load File 2007-07-09 09:24:49
Thông thường khi thì chúng ta sẽ để đường link tuỵêt đối, nhưng đôi lúc vì một lý do nào đó bạn lại không muốn để cho người khác biết link của bài hát, cách thực hiện nhu sau:
- Tạo file song-stream.php có nội dung nhu sau:
<?php
####################################
# PHP Group VN
# web: www.phpbasic.com
# mail: w2ajax@gmail.com
####################################
$name = $tempDir . $_GET["file"];
$fd = fopen($name, 'rb');
if($fd == false)
die("<font color=red>File not found.</font>");
// send the right headers
header("Cache-Control: ");// leave blank to avoid IE errors
header("Pragma: ");// leave blank to avoid IE errors
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename="" . $_GET["file"] . """);
header("Content-length:".(string)(filesize($name)));
sleep(1);
session_write_close();
ob_flush();
flush();
while(!feof($fd)) {
$buffer = fread($fd, 2048);
print $buffer;
}
fclose ($fd);
exit;
?>
Trong HTML noi mà bạn đặt đường link sẽ là song-stream.php?file=tenbaihat
Tác giả: w2ajax
Tra loi 1 comment(s) 2007-07-09 09:24:49
GnuhNguyen 2008-02-17 09:18:57
Tra loi
Y kien