1. Christoffer Niska
  2. yii-img
  3. Issues
Issue #4 new

Property "Image.path" is read only.

Emma Arbogast
created an issue

I get this error when I try to set my own path with $model->saveImage.

Property "Image.path" is read only.

Investigating this, I found what seems like an explanation in the forum: http://www.yiiframework.com/forum/index.php/topic/21044-solved-property-modelattribute-is-read-only/

The forum posts suggests that the method in the model named getPath() interferes with the magic getter and produces this error.

Comments (1)

  1. Benoit Osterberger

    I found the solution to this problem: You should add 'path' to your Image table in db

    new schema:

    CREATE TABLE `Image` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `name` varchar(255) NOT NULL,
        `path` varchar(255) NOT NULL,
        `extension` varchar(255) NOT NULL,
        `filename` varchar(255) NOT NULL,
        `byteSize` int(10) unsigned NOT NULL,
        `mimeType` varchar(255) NOT NULL,
        `created` timestamp NULL DEFAULT NULL,
        PRIMARY KEY (`id`)

    I also found there was another attribute called 'deleted' that was not added in the db schema. maybe it was just for future improvements.

  2. Log in to comment