通过php程序进行文件下载

<?php

$file_name = $_GET['file'] . ".apk";

$file_dir = $_SERVER['DOCUMENT_ROOT'] . "\\";

if(!file_exists($file_dir . $file_name)) {

echo "file is not exists";

} else {

$file = fopen($file_dir . $file_name, "r");

header("Content-type: application/vnd.android.package-archive");

header("Accept-Ranges: bytes");

header("Accept-Length: ".filesize($file_dir . $file_name));

header("Content-Disposition: attachment; filename=" . $file_name);

echo fread($file,filesize($file_dir . $file_name));

fclose($file);

exit;
}
?>
posted @ 2012-02-22 19:01  fighter  阅读(434)  评论(1编辑  收藏  举报