drgbpq5930 2016-08-07 22:19
浏览 152
已采纳

如何在标头中传递多个文件扩展名参数?

I have files of different extensions, So how can I define multiple extensions in one header. for example

 header("Content-type: application/xml"); 
 header("Content-type: application/txt");

Is there any possibilities are there, to define in a single header something like this

 header("Content-type: application/xml txt"); 

Thanks in advance for your suggestions

  • 写回答

1条回答 默认 最新

  • douweiluo0600 2016-08-07 22:37
    关注

    If you want in downloading any type of file you can just use application/octet-stream.

    header('Content-Type: application/octet-stream');
    

    // for example this will download any type of file

     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename="' . basename($file) . '"');
     header('Expires: 0');
     header('Cache-Control: must-revalidate');
     header('Pragma: public');
     header('Content-Length: ' . filesize($file));
     readfile($file);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部