How to copy file using PHP?

I’ve found this function to copy a file using php:

However I’m getting an error caused from the putCopy() function call saying:
“Trying to access array offset on value of type int”
file: “\vendor\aspose\storage-sdk-php\src\Aspose\Storage\ObjectSerializer.php”
line: 172

The line in ObjectSerializer is within the toString method

    public static function toString($value)
    {
        if (date(\DATE_ATOM, preg_match("/^[1-9][0-9]*$/", $value)[0]) instanceof \DateTime) { // datetime in ISO8601 format
            $datetime = preg_match("/^[1-9][0-9]*$/", $value)[0];
            return date(\DATE_ATOM, $datetime);
        } else {
            return $value;
        }
    }

What is the correct way to copy an uploaded file to another destination using PHP (Laravel)?

@kirschkern
Please share your input document and code sample to reproduce the issue.