• <bdo id='MQFdD'></bdo><ul id='MQFdD'></ul>

    <small id='MQFdD'></small><noframes id='MQFdD'>

    <legend id='MQFdD'><style id='MQFdD'><dir id='MQFdD'><q id='MQFdD'></q></dir></style></legend>

        <tfoot id='MQFdD'></tfoot>
        <i id='MQFdD'><tr id='MQFdD'><dt id='MQFdD'><q id='MQFdD'><span id='MQFdD'><b id='MQFdD'><form id='MQFdD'><ins id='MQFdD'></ins><ul id='MQFdD'></ul><sub id='MQFdD'></sub></form><legend id='MQFdD'></legend><bdo id='MQFdD'><pre id='MQFdD'><center id='MQFdD'></center></pre></bdo></b><th id='MQFdD'></th></span></q></dt></tr></i><div id='MQFdD'><tfoot id='MQFdD'></tfoot><dl id='MQFdD'><fieldset id='MQFdD'></fieldset></dl></div>

        php文件强制下载

        时间:2023-08-20

          <legend id='Ukugp'><style id='Ukugp'><dir id='Ukugp'><q id='Ukugp'></q></dir></style></legend>

              1. <tfoot id='Ukugp'></tfoot>
                  <bdo id='Ukugp'></bdo><ul id='Ukugp'></ul>

                    <tbody id='Ukugp'></tbody>
                  <i id='Ukugp'><tr id='Ukugp'><dt id='Ukugp'><q id='Ukugp'><span id='Ukugp'><b id='Ukugp'><form id='Ukugp'><ins id='Ukugp'></ins><ul id='Ukugp'></ul><sub id='Ukugp'></sub></form><legend id='Ukugp'></legend><bdo id='Ukugp'><pre id='Ukugp'><center id='Ukugp'></center></pre></bdo></b><th id='Ukugp'></th></span></q></dt></tr></i><div id='Ukugp'><tfoot id='Ukugp'></tfoot><dl id='Ukugp'><fieldset id='Ukugp'></fieldset></dl></div>

                  <small id='Ukugp'></small><noframes id='Ukugp'>

                  本文介绍了php文件强制下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我使用此代码下载此图像(仅用于测试目的)时,我打开下载的图像,它给我的只是一个错误.我在 chrome 中试过了.用windows photo viewer 打开它,它说它无法显示图片,因为它是空的???这是代码:

                  When I use this code to download this image (only used for testing purposes), I open the downloaded image, and all it gives me is an error. i tried it in chrome. opening it with windows photo viewer, it says that it can't display the picture because it is empty??? here is the code:

                  <?PHP
                   // Define the path to file
                   $file = 'http://www.media.lonelyplanet.com/lpi/12553/12553-11/469x264.jpg';
                  
                   if(!file)
                   {
                       // File doesn't exist, output error
                       die('file not found');
                   }
                   else
                   {
                       header('Content-Description: File Transfer');
                          header('Content-Type: application/octet-stream');
                          header('Content-Disposition: attachment; filename='.basename($file));
                          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($file));
                          ob_clean();
                          flush();
                          readfile($file);
                          exit;
                   }
                   ?>
                  

                  推荐答案

                  我有机会解决这个问题.您的问题有两个方面.

                  I've had a chance to work it out. Your problem is two-fold.

                  首先,从 url 中删除 www..

                  First, remove the www. from the url.

                  其次,删除对 filesize($file) 的调用,该调用会引发错误,因为 PHP 在下载文件之前不知道文件的大小.(真的,只需删除整行)

                  Second, remove the call to filesize($file) which is throwing an error because PHP doesn't know the size of the file before it downloads the file. (really, just remove the whole line)

                  去掉这两个东西,我就成功了.

                  Removing these two things, I was successful.

                  这篇关于php文件强制下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP 强制下载导致 0 字节文件 下一篇:为什么我下载的文件总是损坏或损坏?

                  相关文章

                  <i id='mYFi1'><tr id='mYFi1'><dt id='mYFi1'><q id='mYFi1'><span id='mYFi1'><b id='mYFi1'><form id='mYFi1'><ins id='mYFi1'></ins><ul id='mYFi1'></ul><sub id='mYFi1'></sub></form><legend id='mYFi1'></legend><bdo id='mYFi1'><pre id='mYFi1'><center id='mYFi1'></center></pre></bdo></b><th id='mYFi1'></th></span></q></dt></tr></i><div id='mYFi1'><tfoot id='mYFi1'></tfoot><dl id='mYFi1'><fieldset id='mYFi1'></fieldset></dl></div>

                • <legend id='mYFi1'><style id='mYFi1'><dir id='mYFi1'><q id='mYFi1'></q></dir></style></legend>
                    • <bdo id='mYFi1'></bdo><ul id='mYFi1'></ul>

                      <tfoot id='mYFi1'></tfoot>

                      <small id='mYFi1'></small><noframes id='mYFi1'>