Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Upload creates ghost file
  • Hi there!

    If got a problem with the Upload class (Version 1.6 says oil. But I downloaded it two days ago.). I'm running more or less the same code as in Version 1.5:

                    $config = array(
                        'path' => DOCROOT.'assets/img/homeimgs/',
                        'randomize' => true,
                        'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),
                    );

                    Upload::process($config);

                    if (Upload::is_valid()) {
                        Upload::save();
                    }

                    $homeImg = Model_HomeImg::forge(array(
                        'is_draft' => Input::post('is_draft') ? 0 : 1, // kinda confusing. the customer sets "public: true"
                        'file_path' => Upload::get_files()[0]['saved_as'],
                    ));

    I select only one file (a simple test.png) which is uploaded and named to something random. But another file created too. With the same name. The file gets named accordingly suffixed with _1. The file takes up 0 bytes (says Finder).

    Is this a known issue? Or just me not reading the releases notes?
  • HarroHarro
    Accepted Answer
    You probably have auto_process enabled in the upload config.

    Before 1.6, you could get away with auto processing, and then calling process() yourself as well. As of 1.6, you can no longer.

    If you need to process() manually, disable auto_process in the config.
  • I can confirm this behaviour, if auto_process is set to true the upload runs twice.
    Same happened to me in another project.
  • Same here.  

    I am also seeing 2 errors when I send up an invalid file type.  
    If I lock up the directory (0555) I am not seeing any errors.   :(

    Testing more with auto_process off.
     
  • I disabled auto_process in the config array I use as an argument in the Upload::process() call. The files are saved correctly, but still two files with the same name are created. It's like the auto_process value is ignored.

    I had to disable auto_process in the upload.php-config file.

    And right now the docs are misleading.
  • Can you explain where, and what you think is misleading? So we can correct them?
  • The usage example will produce the ghost-file effect.
  • I've just pushed a fix (to 1.7/develop) that should prevent double processing if auto_process is enabled in the configuration.
  • Same problem occurs here...i have 'auto_process' set to true in general config file...if i use new set of configs(with 'auto_process' => false) while uploading it still calls process twice and uploading a ghost file.

    composer.json says im using "fuelphp/upload": "2.0"
  • "fuelphp/upload": "2.0.1"

    is the latest version, and used in 1.7.1.

    You can not set "auto_process" to false by passing config, you have to change it in the config file. It is a flag checked in the class init, which is processed as soon as the class loads. If you intend to use Upload with a custom config and not with the config from the upload.php config file, you should set auto_process to false.

Howdy, Stranger!

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

In this Discussion