get_temp_dir()

最后更新于:2021-11-27 00:54:23

get_temp_dir()

Determine a writable directory for temporary files.

响应

(string) Writable temporary directory.

源文件

文件: gc-includes/functions.php

function get_temp_dir() {
	static $temp = '';
	if ( defined( 'GC_TEMP_DIR' ) ) {
		return trailingslashit( GC_TEMP_DIR );
	}

	if ( $temp ) {
		return trailingslashit( $temp );
	}

	if ( function_exists( 'sys_get_temp_dir' ) ) {
		$temp = sys_get_temp_dir();
		if ( @is_dir( $temp ) && gc_is_writable( $temp ) ) {
			return trailingslashit( $temp );
		}
	}

	$temp = ini_get( 'upload_tmp_dir' );
	if ( @is_dir( $temp ) && gc_is_writable( $temp ) ) {
		return trailingslashit( $temp );
	}

	$temp = GC_CONTENT_DIR . '/';
	if ( is_dir( $temp ) && gc_is_writable( $temp ) ) {
		return $temp;
	}

	return '/tmp/';
}