Quick Way to Find PHP’s Temp Folder

If you want to know what folder (in Linux), that PHP is using for temps, you can always check the php.ini. However, the setting for temp folder is often commented out, leaving the “system default” as the folder of choice. But what is that?

One way is to just type “df” at the command line, chances are good you’ll see the symlink path to temp in here. In fact most of the time it’ll just be “/tmp/” anyway. But here is one more trick.

Create a php file and just put this code in it:

<?php
    $temp_file = tempnam(sys_get_temp_dir(), 'Tux');
    echo $temp_file;
?>

Run that on your server and it should give you a pathname to the created temp file. You’ll know for sure what PHP is using.

Your Thoughts Matter!...