Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 4444 to 4472

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 19th March 2024 09:35 Europe/London time based on the source file dated 11th March 2024 14:25 Europe/London time.