PHP 实现下载文件的方法_PHP教程

WBOY
Freigeben: 2016-07-20 11:12:52
Original
757 Leute haben es durchsucht

<span  1</span> <span 方法一:
</span><span  2</span> <span header</span>('Content-Description: File Transfer'<span );
</span><span  3</span> <span header</span>('Content-Type: application/octet-stream'<span );
</span><span  4</span> <span header</span>('Content-Disposition: attachment; filename='.<span basename</span>(<span $filepath</span><span ));
</span><span  5</span> <span header</span>('Content-Transfer-Encoding: binary'<span );
</span><span  6</span> <span header</span>('<span Expires: 0&prime;);
</span><span  7</span> header('Cache-Control: must-revalidate, post-check=0, pre-check=0<span &prime;);
</span><span  8</span> <span header</span>('Pragma: public'<span );
</span><span  9</span> <span header</span>('Content-Length: ' . <span filesize</span>(<span $filepath</span><span ));
</span><span 10</span> <span readfile</span>(<span $file_path</span><span );
</span><span 11</span> 
<span 12</span> <span 方法二:
</span><span 13</span> <span $fileinfo</span> = <span pathinfo</span>(<span $filename</span><span );
</span><span 14</span> <span header</span>('Content-type: application/x-'.<span $fileinfo</span>['extension'<span ]);
</span><span 15</span> <span header</span>('Content-Disposition: attachment; filename='.<span $fileinfo</span>['basename'<span ]);
</span><span 16</span> <span header</span>('Content-Length: '.<span filesize</span>(<span $filename</span><span ));
</span><span 17</span> <span readfile</span>(<span $thefile</span><span );
</span><span 18</span> <span exit</span>();
Nach dem Login kopieren

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440424.htmlTechArticle('Content-Description: File Transfer' ('Content-Type: application/octet-stream' ('Content-Disposition: attachment; filename='. ( ('Content-Transfer-Encoding: binary' (' header('Cac...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage