【问题标题】:phpThumb write test FAILEDphpThumb 写入测试失败
【发布时间】:2016-08-29 02:54:47
【问题描述】:

我正在尝试将我的 PHP 网站部署在带有 IIS7 的 Godaddy Windows 共享主机中。 我的网站使用 phpThumb 库来生成拇指图像。

但是没有显示缩略图,我得到了:

用法:/########/filename.jpg 详细阅读用法 cmets

当我检查phpThumb.demo.check.php时,缓存写入测试出现红色错误如下

D: / Hosting / ########### / cache / 6 / 67 / 67c / 67c4 / phpThumb_cache_########__raw67c44e91c46b79493d95da579a7fef28_par52b4fbd9e2256843fcdbe9d1f35f2875.jpeg
directory does NOT exist (before EnsureDirectoryExists())
directory does NOT exist (after EnsureDirectoryExists())
write test FAILED

D: / Hosting / ########### / 缓存目录已经存在,并且已经从 godaddy 文件管理器更改为可写。

但我注意到“缓存目录”和“临时目录”检查结果都是“存在/可读/可写”。

为什么 phpThumb 给出“写测试失败”,尽管缓存目录是存在/可读/可写的?当我检查缓存文件夹时,CacheStart.txt 文件被创建。

【问题讨论】:

    标签: php caching permissions phpthumb


    【解决方案1】:

    对于 Godaddy Windows 共享托管,我做了以下更改并为我工作。可能还有其他更好的解决方案,但我只是尝试快速更改为我工作。

    在 phpthumb.functions.php //它将修复在缓存目录中创建子文件夹,可选没有它缓存将不会生成

    static function EnsureDirectoryExists($dirname) {
        $dirname = str_replace('/', DIRECTORY_SEPARATOR, $dirname);  //added for godaddy
        $directory_elements = explode(DIRECTORY_SEPARATOR, $dirname);
        $startoffset = 5;  //added for godaddy
    
        /*  comment for godaddy
        $startoffset = (!$directory_elements[0] ? 2 : 1);  // unix with leading "/" then start with 2nd element; Windows with leading "c:\" then start with 1st element
        $open_basedirs = preg_split('#[;:]#', ini_get('open_basedir'));
        foreach ($open_basedirs as $key => $open_basedir) {
            if (preg_match('#^'.preg_quote($open_basedir).'#', $dirname) && (strlen($dirname) > strlen($open_basedir))) {
                $startoffset = count(explode(DIRECTORY_SEPARATOR, $open_basedir));
                break;
            }
        }
        */
        $i = $startoffset;
        .....
    

    在 phpthumb.class.php //它是必需的,没有它 sourcefilepath 出错了

    function ResolveFilenameToAbsolute($filename) {
        ....
        if ($this->iswindows) {
            //$AbsoluteFilename = preg_replace('#^'.preg_quote(realpath($this->config_document_root)).'#i', realpath($this->config_document_root), $AbsoluteFilename);
            $AbsoluteFilename = str_replace(DIRECTORY_SEPARATOR, '/', $AbsoluteFilename);
        .....
    

    【讨论】:

      猜你喜欢
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 2017-12-25
      • 1970-01-01
      • 2011-01-17
      相关资源
      最近更新 更多