Home > Backend Development > PHP Tutorial > init.php file PHP implementation file download

init.php file PHP implementation file download

WBOY
Release: 2016-07-28 08:29:41
Original
1043 people have browsed it

<span> 1</span><span>public</span><span>function</span><span> get_download_file()
</span><span> 2</span><span>{
</span><span> 3</span><span>header</span> ( 'Content-Description: File Transfer'<span> );
</span><span> 4</span><span>header</span> ( 'Content-Type: application/octet-stream'<span> );
</span><span> 5</span><span>header</span> ( 'Content-Disposition: attachment; filename=' . <span>basename</span> ( <span>$file</span><span> ));
</span><span> 6</span><span>header</span> ( 'Content-Transfer-Encoding: binary'<span> );
</span><span> 7</span><span>header</span> ( 'Expires: 0'<span> );
</span><span> 8</span><span>header</span> ( 'Cache-Control: must-revalidate'<span> );
</span><span> 9</span><span>header</span> ( 'Pragma: public'<span> );
</span><span>10</span><span>header</span> ( 'Content-Length: '  .  <span>filesize</span> ( <span>$file</span><span> ));
</span><span>11</span><span>ob_clean</span><span> ();
</span><span>12</span><span>flush</span><span> ();
</span><span>13</span><span>readfile</span> ( <span>$file</span><span> );
</span><span>14</span><span>exit</span><span>;
</span><span>15</span> }
Copy after login

The above introduces the init.php file and PHP implementation file download, including the content of the init.php file. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template