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 3914 to 3942

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_hook hook('createtempfile_copy''', array($path$tmpfile));
    if(
$copy_hook == false)
        {
        
copy($path$tmpfile);
        }
    else
        {
        
$tmpfile $copy_hook;
        }

    return 
$tmpfile;
    }

This article was last updated 15th May 2021 00:35 Europe/London time based on the source file dated 11th May 2021 10:25 Europe/London time.