Kirby 2.2 - (old) bug while replacing images (on some servers)

##Using Kirby 2.1 I was not able to replace an existing image-file.

Even when both files had the same extension (and filename) I got this error;

In Kirby 2.2 the same error exist;


  1. Upload a new image - no problem
  2. Try to replace that image with another image (with the same extension) - error message
  3. Try to replace that image with exact the same image (just to be sure) - error

In both Kirby 2.1 and 2.2 I managed to “solve” this bug, by making the replace-function the same as the upload-function (which of course is nasty to do).

See the code below for Kirby 2.2 - (file /panel/app/controlers/files.php)


  public function replace($id, $filename) {

    $page = $this->page($id);
    $file = $this->file($page, $filename);

    try {
//    $file->replace();
      $page->upload();
      $this->notify(':)');
    } catch(Exception $e) {
      $this->alert($e->getMessage());
    }

    $this->redirect($file);

  }

I disabled the replace() call and set a new upload() call instead.

Now I can replace images on my server(s), but they must have the same new as the old one - because it’s an upload function, not a replace function…

Tested on XAMPP (newest version) and two (shared) servers.

On a dedicated server, everything works out of the box, but I do not always have clients, using dedicated ones…

This is weird. It means that your server is not able to detect the mime type of the file. Any chance I can access one of your servers that has that issue and make some tests? I never ran into this myself, even on various shared hosting packages. bastian@getkirby.com

Hi,

I had the same issue before (with Kirby 2.1), and it happened on different servers (not very low-cost, but also not very high-end).

Even my local XAMPP server (newest version, newest PHP installation) gives this error.

I will setup a test-case and send you the panel- and ftp-credentials -> but I can not alter the php.ini / php.config on that server (which may be the problem - but not all hosting providers allow you to alter these settings).

Thanks in advance!

update - Thanks to the support of Bastian / Kirby I was able to solve this issue.

Some hosting-providers do not activate the FileInfo Extension by default, which causes an error while replacing an image.

But 9 out of 10 times you can go to your ©Panel, choose something like “advance / php / settings” and activate the extension manually.

As for XAMPP - this can be replaced by MAMP which has some more advanced (secure) settings.