Php downloading code is not easy to use in Apple! Solution

Source: Internet
Author: User
Tags php download website server
Php downloading code is not easy to use in Apple! PHPcode $ filefopen ($ filename, & quot; r & quot;); Header (& quot; Content-type: applicationoctet-stream & quot;); Header (& quot; accept-Ranges: bytes & quo php download code, which is not easy to use in Apple!
PHP code
  $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);

At the beginning, I directly output the content to the page. Later I found another function.
PHP code
  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;        }         }

The effect is the same. please solve it!

The following is a conversation between me and a person:

Just give the resource address to Apple's interface.

Question

That is to say, directly set the link address as the file address, right! I tried it. The Download box is not displayed, and the page is directly output!

Answer

I have just asked about the mobile phone group. Apple's operating system is different from windows. it has no permission to download things. even if it can download things, Apple will not allocate you a bucket to store resources. Apple only recognizes applications and allocates a certain amount of storage space to applications. to allow Apple to download resources, go through the application channel.

Question

But I usually use Apple's operating system to download things! The download prompt box is displayed when you click download on the Internet! However, you are not sure what operating system the website server uses. Do you mean that the Apple server does not provide download? Is it true that all websites that use Apple as servers do not have the download function?




------ Solution --------------------
Discussion
PHP code

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

------ Solution --------------------
Discussion

Browser can download http://www.duote.com/soft/2054.html on this page click download can pop up the download box!

------ Solution --------------------
Are these parameters useful?
Http://apps.hi.baidu.com/share/detail/35570157
Http://blog.csdn.net/starzxf/article/details/6746876
Http://iask.sina.com.cn/ B /6263205

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.