【发布时间】:2011-08-29 03:04:50
【问题描述】:
每个人。
我正在使用 image resizer script 来调整 JPG 图像的大小。它在 my 远程服务器上运行良好,但不幸的是它在客户端的服务器上不起作用。 :-|
目录是可写的(权限设置为 777)。我得到的只是:
Error: image does not exist: /home/content/u/s/e/username/correct/path/to/existing/file.jpg
以下是可能有助于调试的代码:
// Images must be local files, so for convenience we strip the domain if it's there
$image = preg_replace('/^(s?f|ht)tps?:\/\/[^\/]+/i', '', (string) $_GET['image']);
// ...
// Strip the possible trailing slash off the document root
$docRoot = preg_replace('/\/$/', '', DOCUMENT_ROOT);
//...
if (!file_exists($docRoot . $image))
{
header('HTTP/1.1 404 Not Found');
echo 'Error: image does not exist: ' . $docRoot . $image;
exit();
}
请注意,作为开发人员,我已获得访问根目录子目录的权限。
我希望我把问题案例说清楚了。我不知道幕后发生了什么。非常感谢您的帮助
【问题讨论】:
-
您的
preg_replace将因简单的 http 请求而失败(您的请求仅匹配安全(s)协议。不确定在这种情况下是否重要。 -
@brombomb,感谢您指出这一点。我想这不是问题,因为它在我的服务器上没有任何问题。
标签: php file-permissions directory-permissions