phpThumb cache problems

8.2k views Asked by At

I'm using phpThumb - the PHP thumbnail generator.

'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.

4

There are 4 answers

0
Adam Hopkinson On

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?

0
Cabeludo On

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.

0
siconet On

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!

0
tonnyz On

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