I am using a little PHP script on my site called timthumb.php. The script crops and resizes images on the fly and creates a folder called cache
in the same location as the script where it stores the new images.
Is it possible somehow in PHP to write a line of code in another file which can replace the line of code in timthumb.php where the 'cache' folder location is defined?
I've had a look in timthumb.php and on line 40 is the following:
if(! defined('FILE_CACHE_DIRECTORY')) define ('FILE_CACHE_DIRECTORY', './cache');
I've experimented with changing the last part ./cache
to for example ../../../uploads
and this works fine. My only reservation with doing this is it'll be lost if/when timthumb.php is next updated, so I wondering if there might be another solution.
Sorry if this is a dumb question. I am new to PHP.
In the script that loads
timthumb.php
add the following line before the call toinclude
.and change
./cache
to wherever you want your cache to be.Explanation: The script checks if the constant
FILE_CACHE_DIRECTORY
was defined by you, if not it will use the default value (./cache
).