$file   =   fopen($filename, "r ");
Header( "Content-type:   application/octet-stream ");
Header( "Accept-Ranges:   bytes ");
Header( "Accept-Length:".filesize($filename));
Header( "Content-Disposition:attachment;filename= ".$filename);
echo   fread($file,filesize($filename));
fclose($file);
刚开始用的这个,直接就把内容输出到页面上了。后来又找了个函数function download_file($archivo, $downloadfilename = null) {
 
    if (file_exists($archivo)) {
        $downloadfilename = $downloadfilename !== null ? $downloadfilename : basename($archivo);
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename=' . $downloadfilename);
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Length: ' . filesize($archivo));
 
        ob_clean();
        flush();
        readfile($archivo);
        exit;
    }
 
}效果还是一样,求高手解决!下面是我和一个人的对话:苹果的接口直接给资源地址就行了 追问就是说 直接将链接地址设为文件的地址,对吧!   我试过了,不会弹出下载框,也是直接输出要页面!回答我刚问过手机组,苹果的操作系统跟windows不同,没有权限下载东西,即使可以下载东西,苹果也不会分配给你存储空间去存储资源。苹果只会识别应用,并且给应用分配一定的空间存储,若要让苹果下载资源,请走应用渠道。追问但是我平时有用苹果的操作系统下载东西啊!   就是在网上点下载的时候会弹出下载提示框的!  但是不确定该网站的服务器用的是什么操作系统。  你的意思是不是,苹果的服务器不提供下载?  那么是不是所有拿苹果当服务器的网站都没有下载的功能?

解决方案 »

  1.   


    你错误的地方在于苹果的东西还分 ipad 平板电脑系统(手机系统) 和 mac 电脑系统。 在平板电脑(手机)上就像你问的那个人说的是不允许下载东西的,得开发成应用程序。
    但是苹果电脑mac是跟我们平时使用的系统类似的。
    所以你的东西到底是开发提供给什么人使用 什么环境,先弄清楚。如果是手机 平板电脑那就不用研究了。如果是提供给mac台式电脑用户那么遵循协议就行了。
      

  2.   


    额,搞清楚了!   我现在就是mac台式电脑,用的mamp的php+mysql的开发环境。  代码室php的,我的这段代码有什么问题呢?为什么实现不了下载?
      

  3.   

    先确认你的电脑上的浏览器是否能从网上下载文件
    如果能,请贴出 url
      

  4.   

    这样?
    <?php
    ob_start();
    $im = imagecreateturecolor(100,20);
    $white = imagecolorallocate($error_im,255,255,255);
    $black = imagecolorallocate($error_im,0,0,0);
    imagefttext($im,12,0,0,0,$black,'font.ttf','Hello, world!');
    imagegif($im);
    ob_flush();
    ?>
    <?php
    for ($i=0; $i<10; $i++) {
      ob_start();  echo "This is iteration $i: ";  // * Don't do this!
      // $buf = ob_get_contents();
      // ob_clean();  // * Use this instead:
      $buf = ob_get_clean();  echo $buf;
      
      echo memory_get_usage()."\n";
    }
    ?>
      

  5.   

    浏览器可以下载   http://www.duote.com/soft/2054.html    这个页面上点击下载可以弹出下载框!
      

  6.   

    他那是直接下载 http://51.duote.org/thunder.exe
    并未经 php 转接
      

  7.   

    可不可以这么说?我的php下载代码其实是没有问题的!        如果我要直接下载,把链接地址改成改文件路径就可以了对吧?  我试过了,在mac下拿火狐浏览器点击一个psf的文件可以弹出下载对话框,但是点击一个txt和jpg的文件会直接显示在页面上!   而我用safari浏览器不管室哪个文件都只会显示在页面上!   现在我想不管是什么文件都可以弹出下载提示框,该如何实现?
      

  8.   

    这些参数看看有用没?
    http://apps.hi.baidu.com/share/detail/35570157
    http://blog.csdn.net/starzxf/article/details/6746876
    http://iask.sina.com.cn/b/6263205
      

  9.   

    好,谢谢了!  我想到别的方法了,我发现下载.zip    .rar   的这种压缩文件都会弹出提示框,所以我在文件上传的页面限制了,只能上传.zip    .rar   的文件。