开发者

phpThumb cache problems

开发者 https://www.devze.com 2022-12-10 08:10 出处:网络
I\'m using phpThumb - the PHP thumbnail ge开发者_运维百科nerator. \'phpThumb.config.php\': $PHPTHUMB_CONFIG[\'cache_maxage\'] = 10;

I'm using phpThumb - the PHP thumbnail ge开发者_运维百科nerator.

'phpThumb.config.php':

$PHPTHUMB_CONFIG['cache_maxage'] = 10; 

$PHPTHUMB_CONFIG['cache_maxsize'] = 1000; 

$PHPTHUMB_CONFIG['cache_maxfiles'] = 10;   

but it does nothing... I've got 108 MB in 922 files... and it keeps growing.


For me the solution was really simple. After installing phpthumb with the default settings the line $PHPTHUMB_CONFIG['document_root'] = realpath((getenv('DOCUMENT_ROOT') && ereg('^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))), realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__)))); wasn't uncommeted and all seems to work fine.

BUT: the /tmp directory runs out of space in very short time on a high frequented page.

SOLUTION: It was simple, since phpthumb needs WRITE PERMISSIONS on its $PHPTHUMB_CONFIG['cache_directory'] directory. So be sure that the user who executes your php scripts (usually apache) has the permission to write, otherwise the /tmp directory will be used and filled up with your cached files.

hope this helps!


I'd check that the user that php is running as has write permissions on the cache folder.

Have you checked the php error log?


funny, in phpThumb.config.php default line was uncommented:

$PHPTHUMB_CONFIG['document_root'] = realpath((getenv('DOCUMENT_ROOT') && ereg('^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))), realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__))));

..and phpThumb succeed in saving files into 'cache' dir, but was unable to delete any files.

I setted $PHPTHUMB_CONFIG['document_root'] mannualy and it works!

So, doublecheck if $PHPTHUMB_CONFIG['document_root'] is correct.


it's simple, you just delete the cache folder. phpThumb will re-create your thumb later.

0

精彩评论

暂无评论...
验证码 换一张
取 消