gpt4 book ai didi

外部 URL 的 PHP readfile()

转载 作者:可可西里 更新时间:2023-11-01 12:26:45 25 4
gpt4 key购买 nike

我可以在 readfile() 中使用外部 URL 吗?

    header('Content-type: application/pdf');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: inline; filename="'.$file.'" ');
//header('Content-Length: ' . filesize("http:...z/pub/".$file.'.pdf'));
@readfile("http://...z/pub/".$file.'.pdf');

最佳答案

readfile 上的 PHP 手册状态:

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

作为替代方案,您还可以使用 file_get_contents:

echo file_get_contents("http://...z/pub/".$file.'.pdf');

关于外部 URL 的 PHP readfile(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4752389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com