dongxun4110 2010-10-10 17:58 采纳率: 0%
浏览 52
已采纳

download.php源代码

when I try to download from some servers, I`m redirected to a download.php page, which can contain many things, then the file download starts.

I want to know how to track my downloads using this download.php file. I mean I want to know how to write this file and what are the contents of this file.

  • 写回答

2条回答 默认 最新

  • dongxixia6399 2010-10-10 18:03
    关注

    You mean you want to have your own download.php page that is like the one used by so many others? Here is one of mine:

    header('Content-disposition: attachment;filename=file.js');
    header('Content-type: text/javascript');
    readfile($_SERVER['DOCUMENT_ROOT'] . '/_js/file.js');
    

    That's pretty much it, this will let you download the file. You have to have the correct filename in readfile() and it usually helps to have the correct content type. There are many, so look up the right one depending upon the file type.

    I don't know how to track whether the user actually downloaded the file .. probably have to look at the server logs or something. It would be very easy to track who got to the download.php page, though. Just have the page stored in your DB and write the number of times the page was viewed +1.

    Here is a pretty nice list of at least some content-types you can use: http://www.utoronto.ca/web/htmldocs/book/book-3ed/appb/mimetype.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分