2012-07-07 64 views
0

我想部署我的PHP网站在Godaddy Windows与IIS7共享主机。 我的网站使用phpThumb库来生成缩略图。phpThumb写测试失败

但不显示图像大拇指,我得到:

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

当我检查使用评论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文件。

回答

0

对于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 //这是必需的,没有它源文件路径出错了

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); 
    .....