Bug #23560 Bug Fixed

Fatal error when uploading and overwriting an existing non-image file to an upload loc that contains manipulations

Version: 4.1.3 Reporter: Derek Jones

  1. Make sure you have an upload directory that allows “All Files” and also has one or more Manipulations set.
  2. Upload a non-image file, e.g. test.txt
  3. Upload the same file again, with the same name
  4. Select ” Replace older file only” in the File conflict resolution form and click “Finish Upload”

Result:

Exception Caught

Cannot copy non-existent path: /path/to/upload/dir/_manipulation_name/test_1.txt

ee/EllisLab/ExpressionEngine/Library/Filesystem/Filesystem.php:339

Stack Trace: Please include when reporting this error

#0 ee/EllisLab/ExpressionEngine/Service/File/Upload.php(472): EllisLab\ExpressionEngine\Library\Filesystem\Filesystem->copy('...', '...')
#1 ee/EllisLab/ExpressionEngine/Controller/Files/Files.php(246): EllisLab\ExpressionEngine\Service\File\Upload->resolveNameConflict('12')
#2 [internal function]: EllisLab\ExpressionEngine\Controller\Files\Files->finishUpload('12')
  • In the resolveNameConflict() method of system/ee/EllisLab/ExpressionEngine/Service/File/Upload.php, around line 468 change:

    foreach ($file->UploadDestination->FileDimensions as $fd)
    {
        $src  = $fd->getAbsolutePath() . $file->file_name;
        $dest = $fd->getAbsolutePath() . $original->file_name;
        ee('Filesystem')->copy($src, $dest);
    }

    to:

    foreach ($file->UploadDestination->FileDimensions as $fd)
    {
        $src  = $fd->getAbsolutePath() . $file->file_name;
        $dest = $fd->getAbsolutePath() . $original->file_name;
    
        if (ee('Filesystem')->exists($src))
        {
         ee('Filesystem')->copy($src, $dest);
        }
    }
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases