12
返回列表 发新帖
楼主: staryshine

请教关于客户端升级程序的PHP脚本

[复制链接]
论坛徽章:
3
授权会员
日期:2005-10-30 17:05:33管理团队2006纪念徽章
日期:2006-04-16 22:44:45会员2006贡献徽章
日期:2006-04-17 13:46:34
11#
发表于 2004-9-28 22:55 | 只看该作者
返回文件的类型就是mime type类型,你可以参考相关文档。
比如GIF图片类型:header('Content-type: image/gif')
如果你要提供文件下载的话,用header('Content-type: application/octet-stream')类型。

使用道具 举报

回复
论坛徽章:
0
12#
 楼主| 发表于 2004-9-29 08:14 | 只看该作者
改成这个样子了。
                     header('Content-type: application/octet-stream');
        $url = "http://202.204.112.206/upgrade/test.php";
        header("Location: $url";
可是还是提示
Warning: Cannot add header information - headers already sent by (output started at /var/www/html/upgrade/index.php:8) in /var/www/html/upgrade/index.php on line 12

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2005-10-30 17:05:33管理团队2006纪念徽章
日期:2006-04-16 22:44:45会员2006贡献徽章
日期:2006-04-17 13:46:34
13#
发表于 2004-9-29 13:49 | 只看该作者
<?php
if (($_GET['m_pszAppName']==Supplicant) && ($_GET['IDS_VERSION']!=1.0)) {
   //以下是为客户端提供下载文件是示例,根据需要适当修改
   $file = fopen($file_dir.$file_name,"r";
       header('Content-type: application/octet-stream');
       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);

}
else {
        echo "UP TO DATE";
}
?>

使用道具 举报

回复
论坛徽章:
0
14#
 楼主| 发表于 2004-9-29 16:46 | 只看该作者
改过了,还是有警告
Warning: Cannot add header information - headers already sent by (output started at /var/www/html/upgrade/index.php:8) in /var/www/html/upgrade/index.php on line 15

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/upgrade/index.php:8) in /var/www/html/upgrade/index.php on line 16

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/upgrade/index.php:8) in /var/www/html/upgrade/index.php on line 17

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/upgrade/index.php:8) in /var/www/html/upgrade/index.php on line 18

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2005-10-30 17:05:33管理团队2006纪念徽章
日期:2006-04-16 22:44:45会员2006贡献徽章
日期:2006-04-17 13:46:34
15#
发表于 2004-9-29 18:10 | 只看该作者
header前不要有任何输出到浏览器

使用道具 举报

回复
论坛徽章:
0
16#
 楼主| 发表于 2004-9-30 09:00 | 只看该作者
header前没有任何输出到浏览器呀

if (($_GET['m_pszAppName']==Supplicant) && ($_GET['IDS_VERSION']!=1.0))
{
              $file_dir = "/var/www/html/upgrade/";
              $file_name = "uploadfile.txt";
              $file = fopen($file_dir.$file_name , "r";
                          Header('Content-type: application/octet-stream');
                          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);

         }
                        else
         {
                                                         
         $url = "UP TO DATE";
        echo $url;
                        }

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2005-10-30 17:05:33管理团队2006纪念徽章
日期:2006-04-16 22:44:45会员2006贡献徽章
日期:2006-04-17 13:46:34
17#
发表于 2004-9-30 11:22 | 只看该作者
我测试了一下,在我这边没有问题,注意最上面不要有空行和空格。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表