Horde::getTempFile PHP Method

getTempFile() public static method

Creates a temporary filename for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.
public static getTempFile ( string $prefix = 'Horde', boolean $delete = true, string $dir = '', boolean $secure = false, boolean $session_remove = false ) : string
$prefix string Prefix to make the temporary name more recognizable.
$delete boolean Delete the file at the end of the request?
$dir string Directory to create the temporary file in.
$secure boolean If deleting file, should we securely delete the file?
$session_remove boolean Delete this file when session is destroyed?
return string Returns the full path-name to the temporary file or false if a temporary file could not be created.
    public static function getTempFile($prefix = 'Horde', $delete = true, $dir = '', $secure = false, $session_remove = false)
    {
        if (empty($dir) || !is_dir($dir)) {
            $dir = self::getTempDir();
        }
        $tmpfile = Horde_Util::getTempFile($prefix, $delete, $dir, $secure);
        if ($session_remove) {
            $gcfiles = $GLOBALS['session']->get('horde', 'gc_tempfiles', Horde_Session::TYPE_ARRAY);
            $gcfiles[] = $tmpfile;
            $GLOBALS['session']->set('horde', 'gc_tempfiles', $gcfiles);
        }
        return $tmpfile;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Creates a temporary copy of a file.
  *
  * @param string $filename  The name of the file to be copied.
  *
  * @return string           The file name of the temporary copy or false
  *                          if the file couldn't be copied.
  */
 function tmpFile($filename)
 {
     $tmp = Horde::getTempFile('luxor');
     if (!@copy($this->toReal($filename), $tmp)) {
         return false;
     }
     return $tmp;
 }
All Usage Examples Of Horde::getTempFile