PHP 实现文件的办法

    添加时间:2013-7-4 点击量:

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


    容易发怒的意思就是: 别人做了蠢事, 然后我们代替他们, 表现出笨蛋的样子。—— 蔡康永
    分享到: