Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

createTempFile()

Description

Create a temporary copy of the file in the tmp folder (ie. the usual filestore/tmp/)

Parameters

ColumnTypeDefaultDescription
$path string File path
$uniqid string If a uniqid is provided, create a folder within tmp. See get_temp_dir() for more information.
$filename string Filename of the new file

Return

boolean|string Returns FALSE or the file path of the temporary file

Location

include/resource_functions.php lines 3835 to 3855

Definition

 
function createTempFile($path$uniqid$filename)
    {
    if(!
file_exists($path) || !is_readable($path))
        {
        return 
false;
        }

    
$tmp_dir get_temp_dir(false$uniqid);

    if(
trim($filename) == '')
        {
        
$file_path_info pathinfo($path);
        
$filename md5(mt_rand()) . "_{$file_path_info['basename']}";
        }

    
$tmpfile "{$tmp_dir}/{$filename}";

    
copy($path$tmpfile);

    return 
$tmpfile;
    }

This article was last updated 29th November 2020 05:05 Europe/London time based on the source file dated 27th November 2020 14:50 Europe/London time.