I use this code in my project bloxool to find a temporary filename.

function bx_tmpfilename() {
   if(!function_exists('sys_get_temp_dir')) {
      if(defined('BLOXOOL_TEMP_DIR')) {
         $temp = BLOXOOL_TEMP_DIR;
      } else {
         $temp = getenv('TMP');
         if($temp === FALSE || empty($temp)) {
            $temp = getenv('TEMP');
            if($temp === FALSE || empty($temp)) {
               $temp = getenv('TMPDIR');
               if($temp === FALSE || empty($temp)) {
                  $temp = '/tmp/';
               }
            }
         }
      }
   } else {
      $temp = sys_get_temp_dir();
   }
   if(!is_writable($temp)) {
      bx_fatal_error(BX_F_ERR_NOTMP);
      exit(-1);
   }
   return tempnam($temp, 'BX');
}
 
php/bx_tmpfilename.txt · Last modified: 2010/02/03 22:43 by tchetch
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Debian Driven by DokuWiki