Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error in Upload class
  • Dear friend,

    I am using FuelPHP-1.9-dev and PHP 8.3 for development.
    I am getting an error when using the Upload class (Fuel\Core\Upload) when trying to process the upload file. Here is part of the code:

    [code]
    // Custom configuration for this upload
    $config = array(
    "path" => Config::get("app.uploads_folder") . $docPath,
    "max_size" => $maxUploadFile,
    "overwrite" => false,
    "normalize" => true,
    "randomize" => true,
    "ext_whitelist" => array("pdf")
    );

    // process the uploaded files in $_FILES
    Upload::process($config);
    [/code]

    The code is interrupted and an error is generated in the framework log file.


    Fatal Error - During inheritance of ArrayAccess: Uncaught Fuel\Core\PhpErrorException: Return type of Fuel\Upload\Upload::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\projects\myproject\fuel\vendor\fuelphp\upload\src\Upload.php:503 Stack trace: #0 D:\projects\myproject\fuel\core\bootstrap.php(112): Fuel\Core\Errorhandler::error_handler(8192, 'Return type of ...', 'D:\\projects\\php...', 503) #1 D:\projects\myproject\fuel\vendor\fuelphp\upload\src\Upload.php(16): {closure}(8192, 'Return type of ...', 'D:\\projects\\php...', 503) #2 D:\projects\myproject\fuel\vendor\composer\ClassLoader.php(576): include('D:\\projects\\php...') #3 D:\projects\myproject\fuel\vendor\composer\ClassLoader.php(427): Composer\Autoload\{closure}('D:\\projects\\php...') #4 [internal function]: Composer\Autoload\ClassLoader->loadClass('Fuel\\Upload\\Upl...') #5 D:\projects\myproject\fuel\core\classes\upload.php(88): class_exists('Fuel\\Upload\\Upl...') #6 [internal function]: Fuel\Core\Upload::_init() #7 D:\projects\myproject\fuel\core\classes\autoloader.php(383): call_user_func('Fuel\\Core\\Uploa...') #8 D:\projects\myproject\fuel\core\classes\autoloader.php(242): Fuel\Core\Autoloader::init_class('Fuel\\Core\\Uploa...', 'D:\\projects\\php...') #9 D:\projects\myproject\fuel\app\classes\controller\admin\recourses.php(456): Fuel\Core\Autoloader::load('Fuel\\Core\\Uploa...') #10 [internal function]: Controller_Admin_Recourses->action_attach('35') #11 D:\projects\myproject\fuel\core\classes\request.php(483): ReflectionMethod->invokeArgs(Object(Controller_Admin_Recourses), Array) #12 D:\projects\myproject\public\index.php(133): Fuel\Core\Request->execute() #13 D:\projects\myproject\public\index.php(180): {closure}() #14 {main} in D:\projects\myproject\fuel\vendor\fuelphp\upload\src\Upload.php on line 16

    Previously, the code was working perfectly, but with the latest framework updates, the reported problem is occurring.
    Thanks for any sugestion.


    Medeiros
  • You seem to be using a very old version of the Upload package, this issue is fixed in https://github.com/fuelphp/upload/commit/79cde2b3e73185062e123db05282f3d4ffe3cac6, 4 years ago.

    Update the Upload package in your main composer.json to at least 2.0.7 (the current version: https://github.com/fuel/fuel/blob/1.9/develop/composer.json) and run a composer update.
  • Dear friend,

    Your observation about the code was absolutely correct; the version of the Upload class was very old (2.0.6). I updated composer.json and now it is working correctly.
    I am very grateful for your kind solution to the problem.
    TIA


    Medeiros

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion