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

collection_download_use_original_filenames_when_downloading()

Parameters

ColumnTypeDefaultDescription
&$filename
$ref
$collection_download_tar
&$filenames
$id ''

Location

include/collections_functions.php lines 4730 to 4789

Definition

 
function collection_download_use_original_filenames_when_downloading(&$filename$ref$collection_download_tar, &$filenames,$id='')
    {
    if(
trim($filename) === '')
        {
        return;
        }

    global 
$pextension$usesize$subbed_original$deletion_array$use_zip_extension$copy$exiftool_write_option,
        
$p$size$lang;

    
# Only perform the copy if an original filename is set.

    # now you've got original filename, but it may have an extension in a different letter case. 
    # The system needs to replace the extension to change it to jpg if necessary, but if the original file
    # is being downloaded, and it originally used a different case, then it should not come from the file_extension, 
    # but rather from the original filename itself.
    
    # do an extra check to see if the original filename might have uppercase extension that can be preserved.   
    # also, set extension to "" if the original filename didn't have an extension (exiftool identification of filetypes)
    
$pathparts pathinfo($filename);
    if (
        isset(
$pathparts['extension'])
        && 
strtolower($pathparts['extension']) == $pextension
        
) {
            
$pextension $pathparts['extension'];
        }

    
$fs=explode("/",$filename);
    
$filename=$fs[count($fs)-1]; 
    
set_unique_filename($filename,$filenames);
   
    
# Copy to tmp (if exiftool failed) or rename this file
    # this is for extra efficiency to reduce copying and disk usage
    
    
if(!($collection_download_tar || $use_zip_extension))
        {
        
// the copy or rename to the filename is not necessary using the zip extension since the archived filename can be specified.
        
$newpath get_temp_dir(false,$id) . '/' $filename;

        if(!
$copy && $exiftool_write_option)
            {
            
rename($p$newpath);
            }
        else
            {
            
copy($p,$newpath);
            }

        
# Add the temporary file to the post-archiving deletion list.
        
$deletion_array[] = $newpath;

        
# Set p so now we are working with this new file
        
$p $newpath;
        }

    if(empty(
$filename))
        {
        
$filename get_download_filename($ref$size0$pextension);
        }
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.