我正在尝试在与IIS7共享主机的Godaddy Windows中部署我的PHP网站。我的网站使用 phpThumb 库生成拇指图像。
但是拇指图像没有显示,我得到:
用法:/####/文件名.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
文件被创建。
对于 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);
.....