Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

makeFilenameUnique()

Description

Make a filename unique by appending a dupe-string.

Parameters

ColumnTypeDefaultDescription
$base_values array
$filename string
$dupe_string string
$extension string
$dupe_increment int null

Return

string Unique filename

Location

include/collections_functions.php lines 4612 to 4626

Definition

 
function makeFilenameUnique($base_values$filename$dupe_string$extension$dupe_increment null)
    {
    
// Create filename to check if exist in $base_values
    
$check_filename $filename . ($dupe_increment $dupe_string $dupe_increment '') . '.' $extension;

    if(!
in_array($check_filename$base_values))
        {
        
// Confirmed filename does not exist yet
        
return $check_filename;
        }

    
// Recursive call this function with incremented value
    // Doing $dupe_increment = null, ++$dupe_increment results in $dupe_increment = 1
    
return makeFilenameUnique($base_values$filename$dupe_string$extension, ++$dupe_increment);
    }

This article was last updated 4th December 2024 09:05 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.