Gargron / fileupload

PHP FileUpload library that supports chunked uploads
MIT License
459 stars 87 forks source link

Trying to access array offset on value of type null #78

Closed christofflueck closed 4 years ago

christofflueck commented 4 years ago

PHP Version: 7.4 Fileupload Version: 1.5.1

When using the Random Filename generator I get this notice:

Notice: Trying to access array offset on value of type null in .....\vendor\gargron\fileupload\src\FileUpload\FileNameGenerator\Random.php on line 70

Which is this line of code: $uploaded_bytes = Util::fixIntegerOverflow(intval($content_range[1]));

TimGa commented 4 years ago

I've faced the same issue... As a workaround I used custom filename generator like that:

// define your own algorithm to get name using provided parameters:
// $source_name, $type, $tmp_name, $index, $content_range, $upload
$filenamegetter = function(
    $source_name,
    $type,
    $tmp_name,
    $index,
    $content_range,
    $upload
) {
    // in my case it is enough just to get original file name
    return $source_name;
};

$pathresolver = new \FileUpload\PathResolver\Simple('/path/to/file');
$filesystem = new \FileUpload\FileSystem\Simple();
$fileupload = new \FileUpload\FileUpload($_FILES['files'], $_SERVER);
// create filename generator with your algorithm
$filenamegenerator = new \FileUpload\FileNameGenerator\Custom($filenamegetter);
// set filename generator for file upload
$fileupload->setFileNameGenerator($filenamegenerator);
$fileupload->setPathResolver($pathresolver);
$fileupload->setFileSystem($filesystem);

list($files, $headers) = $fileupload->processAll();
adelowo commented 4 years ago

This should be fixed by https://github.com/Gargron/fileupload/pull/79

victormacko commented 3 years ago

Was a new version ever tagged & released? ... it's still broken in the latest release :(

Joe45M commented 3 years ago

Can confirm this is still present in v1.5.1

LaurentiuZorila commented 3 years ago

Any news about the release?