Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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 29th May 2024 10:05 Europe/London time based on the source file dated 28th May 2024 17:05 Europe/London time.