Search code examples
phptemp

php set temp directory


Is it possible to change the value that the function sys_get_temp_dir() returns?

My problem is that I don't have write permissions to that directory ( /tmp ) and I can't change that.

Thanks


Solution

  • You can use an environmental variable:

    <?php
    putenv('TMPDIR=/foo/bar');
    echo sys_get_temp_dir(); // Outputs: /foo/bar