文件格式有好多种,音乐文件、图片、文本文档、WORD文档等等,总知道很多。因为我做的是一个资料下载中心,这些文件都放一个目录里。客户端看到是这个目录的文件列表,选择要下载的资料点击就可以下载或保存,不要打开!

解决方案 »

  1.   

    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=待保存的文件名";
    输出文件内容
      

  2.   

    <?
    //打开目录
    $id=opendir("./007");
    $js=0;
    while ($lb=readdir($id))
    {
    $lFiles[$js]=$lb;
    $js++;
    }
    //显示文件列表
    for ($i=0;$i<=$js;$i++)
    {header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=$lFiles[$i]");echo $lFiles[$i];
    }
    closedir($id);
    ?>
    是这样加的吗?
    这样就报错提示如下:
    .<br />
    <b>Warning</b>:  Cannot modify header information - headers already sent by (output started at e:\php\sunel\system-fileslist.php:17) in <b>e:\php\sunel\system-fileslist.php</b> on line <b>14</b><br />
    <br />
    <b>Warning</b>:  Cannot modify header information - headers already sent by (output started at e:\php\sunel\system-fileslist.php:17) in <b>e:\php\sunel\system-fileslist.php</b> on line <b>15</b><br />
    ..<br />
    <b>Warning</b>:  Cannot modify header information - headers already sent by (output started at e:\php\sunel\system-fileslist.php:17) in <b>e:\php\sunel\system-fileslist.php</b> on line <b>14</b><br />
    <br />
    <b>Warning</b>:  Cannot modify header information - headers already sent by (output started at e:\php\sunel\system-fileslist.php:17) in <b>e:\php\sunel\system-fileslist.php</b> on line <b>15</b><br />
    常州软件园招商引资计划2.doc<br />
    <b>Warning</b>:  Cannot modify header information - headers already sent by (output started at e:\php\sunel\system-fileslist.php:17) in <b>e:\php\sunel\system-fileslist.php</b> on line <b>14</b><br />
    <br />
    <b>Warning</b>:  Cannot modify header information - headers already sent by (output started at e:\php\sunel\system-fileslist.php:17) in <b>e:\php\sunel\system-fileslist.php</b> on line <b>15</b><br />
    请帮看看,错在哪里,怎么改!
      

  3.   

    bonniewater(陪你去看海) :
    我有一个文件夹,
    1、我想把它里面的内容列出来
    2、点击列出的文件就可以将该文件保存下来!文件夹路径"./007"