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

is_valid_upload_path()

Description

Confirm upload path is one of valid paths.

Parameters

ColumnTypeDefaultDescription
$file_path string Upload path.
$valid_upload_paths array Array of valid upload paths to test against.

Return

bool true when path is valid else false

Location

include/file_functions.php lines 284 to 311

Definition

 
function is_valid_upload_path(string $file_path, array $valid_upload_paths) : bool
    
{
    
$GLOBALS["use_error_exception"] = true;
    try
        {
        
$file_path realpath($file_path);
        }
    catch (
Exception $e)
        {
        
debug("Invalid file path specified" $e->getMessage());
        return 
false;
        }
    unset(
$GLOBALS["use_error_exception"]);

    foreach(
$valid_upload_paths as $valid_upload_path)
        {
        if(
is_dir($valid_upload_path))
            {
            
$checkpath realpath($valid_upload_path);
            if(
strpos($file_path,$checkpath) === 0)
                {
                return 
true;
                }
            }
        }

    return 
false;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 22nd August 2024 16:45 Europe/London time.