Home Backend Development PHP Tutorial php 下载代码,在苹果下不好用!解决方法

php 下载代码,在苹果下不好用!解决方法

Jun 13, 2016 pm 01:35 PM
content header quot

php 下载代码,在苹果下不好用!

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$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);


Copy after login

刚开始用的这个,直接就把内容输出到页面上了。后来又找了个函数
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
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;
        }
     
    }

Copy after login

效果还是一样,求高手解决!

下面是我和一个人的对话:

苹果的接口直接给资源地址就行了 

追问

就是说 直接将链接地址设为文件的地址,对吧! 我试过了,不会弹出下载框,也是直接输出要页面!

回答

我刚问过手机组,苹果的操作系统跟windows不同,没有权限下载东西,即使可以下载东西,苹果也不会分配给你存储空间去存储资源。苹果只会识别应用,并且给应用分配一定的空间存储,若要让苹果下载资源,请走应用渠道。

追问

但是我平时有用苹果的操作系统下载东西啊! 就是在网上点下载的时候会弹出下载提示框的! 但是不确定该网站的服务器用的是什么操作系统。 你的意思是不是,苹果的服务器不提供下载? 那么是不是所有拿苹果当服务器的网站都没有下载的功能?




------解决方案--------------------
探讨
PHP code

$file = fopen($filename, "r ");
Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Accept-Length:".filesize($filename));
Header( "Content……

------解决方案--------------------
探讨

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

------解决方案--------------------
这些参数看看有用没?
http://apps.hi.baidu.com/share/detail/35570157
http://blog.csdn.net/starzxf/article/details/6746876
http://iask.sina.com.cn/b/6263205
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does linux header mean? What does linux header mean? Jul 18, 2023 pm 03:34 PM

What does linux header mean?

How does SpringBoot pass parameters in the Header through Feign calls? How does SpringBoot pass parameters in the Header through Feign calls? May 16, 2023 pm 08:38 PM

How does SpringBoot pass parameters in the Header through Feign calls?

What is the difference between html5 tag head and header? What is the difference between html5 tag head and header? Jan 17, 2022 am 11:10 AM

What is the difference between html5 tag head and header?

How to use PHP header() method to adjust web pages How to use PHP header() method to adjust web pages Mar 28, 2023 pm 01:54 PM

How to use PHP header() method to adjust web pages

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决

How to jump in php header How to jump in php header Dec 02, 2022 am 09:14 AM

How to jump in php header

How Nginx distributes through the identity in the header How Nginx distributes through the identity in the header May 11, 2023 pm 04:01 PM

How Nginx distributes through the identity in the header

Complete list of PHP file download functions: analysis of file download examples of readfile, header, Content-Disposition and other functions Complete list of PHP file download functions: analysis of file download examples of readfile, header, Content-Disposition and other functions Nov 18, 2023 pm 03:26 PM

Complete list of PHP file download functions: analysis of file download examples of readfile, header, Content-Disposition and other functions

See all articles