Exemple #1
0
    /**
     * Get the temporary dir to store uploaded data
     * @return null|string Path to the temporary directory or null
     */
    function get_temp_dir()
    {
        if ($temp = ini_get('upload_tmp_dir')) {
            return $temp;
        }
        if ($temp = getenv('TMP')) {
            return $temp;
        }
        if ($temp = getenv('TEMP')) {
            return $temp;
        }
        if ($temp = getenv('TMPDIR')) {
            return $temp;
        }
        $temp = tempnam(__FILE__, '');
        if (file_exists($temp)) {
            unlink($temp);
            return dirname($temp);
        }
        if ($temp = sys_get_temp_dir()) {
            return $temp;
        }
        return null;
    }
}
OC::init();