dongpo3957 2015-10-22 15:31 采纳率: 0%
浏览 74
已采纳

如何使用Php自动下载.jar文件

I have looked for an answer for to long, I have the auto download and redirect done, I just need it to make the .jar file download properly. It keeps getting an error when you download and open it.

It says "Error: Invalid or corrupt jarfile C:/path/Final frontier(Pre-Alpha 0.3).jar"

<?php

header("Content-Type: 'application/jar', 'true'");
header('Content-Disposition: attachment; filename="Final frontier (Pre-> Alpha 0.3).jar"');
header("Content-Length: " . filesize("public_html/paid/game/Final frontier (Pre-Alpha 0.3).jar"));

$fp = fopen("public_html/paid/game/Final frontier (Pre-Alpha 0.3).jar", "r");
fpassthru($fp);
fclose($fp);

?>
  • 写回答

1条回答 默认 最新

  • duanjianao0592 2015-10-22 15:48
    关注

    "Thanks you so much!!! That worked! – TJGames 1 min ago"

    Comments to answer, since it solved the question.

    This fopen("public_html/ seems like it may be playing tricks on you. I'd either remove it fopen("paid/ if the script's running from the root, or fopen("../paid/ as an added example, or use a full server path. I.e. fopen("/var/usr/you/public_html/paid/

    Do the same thing for filesize("public_html/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题