PHP即使存在也无法找到文件

时间:2011-08-29 03:04:50

标签: php file-permissions directory-permissions

每个人

我正在使用调整JPG图片大小的image resizer script。它在我的远程服务器上工作正常但不幸的是它在客户端的服务器上不起作用。 : - |

目录是可写的(权限设置为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();
}

请注意,作为开发人员,我被授予访问根目录的子目录的权限。

我希望我能清楚地解决问题。我对幕后发生的事情感到茫然。帮助很难实现

1 个答案:

答案 0 :(得分:1)

PHP必须能够访问导致文件的所有目录,而不仅仅是访问文件本身。如果它没有在所有目录上使用权限,那就是放“免费!拿一个!”的说法。在诺克斯堡内的一个拱顶内的小册子分配器 - 没用。

相关问题