【发布时间】:2014-10-02 08:29:23
【问题描述】:
我在我的一个旧网站上创建了一个图像处理函数,该函数在一个页面上运行,该页面接收图像的完整 URL 作为 get 变量。该函数的一部分使用 get_headers 来获取请求文件的内容类型。
虽然这在我的旧服务器上有效,但我最近搬到了新服务器上,我记得这个页面遇到了各种各样的问题,但我认为这是 GD 库更多的服务器端。
我在运行 php 5.4.X 和 WHm cPanel 的专用服务器上运行该站点,因此我可以根据需要完全更改和安装东西。
麻烦的代码
<?php
//Get the file and set the headers to the file type
$file = $_GET['file'];
$headers = get_headers($file, 1);
header('Content-Type: '.$headers['Content-Type']);
页面响应
Warning: get_headers(): php_network_getaddresses: getaddrinfo failed: Name or service not known in [Removed url] on line 5
Warning: get_headers([Removed url]): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in [Removed url] on line 5
Warning: Cannot modify header information - headers already sent by (output started at [Removed url]:5) in [Removed url] on line 6
我更改服务器端的唯一一件事是在 WHM 中将 allow_url_fopen 设置为打开,我尝试过的所有其他操作在它不起作用后都已重置。
【问题讨论】:
-
您最近多久移动过服务器?如果域尚未传播,则可能是 DNS 问题。