How to use the php define properly

92 views Asked by At

I have this line of php code that sets the main folder of my site as the storage folder. How can I change this to the 'tmp' folder?

define('COOKIELOCAL', str_replace('\\', '/', realpath('./')).'/');

For example mysite.com, I want the files stay in mysite.com/tmp so I can clear this folder using a cron tab, any tips?

In other words what I need is to save the temp files created using this path in the 'tmp' folder instead the root one?

2

There are 2 answers

1
Nathan On BEST ANSWER

I'm not entirely sure why str_replace is being used like it is, but the following should work, while modifying the least from the code you originally posted:

define('COOKIELOCAL', str_replace('\\', '/', realpath('./tmp')).'/');

This would also work:

define('COOKIELOCAL', realpath('./tmp').'/');

Or, as has been suggested in another post:

define('COOKIELOCAL', './tmp/');
6
BenM On

It depends how COOKIELOCAL is ultimately being used, but the following should achieve what you need:

define('COOKIELOCAL', './tmp/');