PHP无法找到文件,即使它存在

PHP无法找到文件,即使它存在,php,file-permissions,directory-permissions,Php,File Permissions,Directory Permissions,各位 我正在使用一个可以调整JPG图像大小的工具。它在我的远程服务器上工作正常,但不幸的是,它在客户端服务器上不工作-| 目录是可写的(权限设置为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 s

各位

我正在使用一个可以调整JPG图像大小的工具。它在我的远程服务器上工作正常,但不幸的是,它在客户端服务器上不工作-|

目录是可写的(权限设置为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();
}
请注意,作为一名开发人员,我已获得访问根目录子目录的权限


我希望我把这个问题讲清楚。我不知道幕后发生了什么。帮助非常重要

PHP必须能够访问指向文件的所有目录,而不仅仅是访问文件本身。如果它在所有目录上都没有权限,那就等于在诺克斯堡的地下室里放了一个“免费!买一本!”的小册子分发器——没用。

你的
preg\u replace
会因为一个简单的http请求而失败(你只有匹配安全的)协议。不确定在这种情况下这是否重要。@brombomb,谢谢你指出这一点。我想这不是问题,因为它在我的服务器上工作没有任何问题。这是否意味着root用户需要更改权限?如果是,应该将其设置为什么?可能,取决于dirs的所有权。以root用户的身份进行操作只会保证你可以换一下烫发。