ユーザ用ツール

OpenPNEについて

OpenPNE一般

画像が添付できない

画像サイズ制限を超過している場合。

画像の添付に失敗する原因の大半は、画像のサイズに起因するものである。 OpenPNE2系の場合は、config.phpにてサイズ制限が課されている。

// アップロード画像のファイルサイズ制限(KB)
define('IMAGE_MAX_FILESIZE', 300);

// アップロード画像の大きさ制限(ピクセル)
// 0 を指定した場合は無制限
define('IMAGE_MAX_WIDTH', 1024);
define('IMAGE_MAX_HEIGHT', 768);

この制限に引っかかっていると画像の添付に失敗する。

データベースの制限に起因する場合

画像サイズは適正なのに、画像が添付できない場合には、データベースの制限に引っかかっている場合が考えられる。 MySQLの場合、4系では、データファイルのサイズは4GBで作られる。5系は、MAX_ROWSの指定を見て、必要に応じて大きく作るようである。多くの場合、制限に引っかかるのは4系のMySQLでの場合だろう。なお、WindowsでFAT32などのファイルシステムを利用していたり、Linux 2.2系のシステムでext2での運用をしている場合には、2GB/4GBという制限がファイルシステムによってかかるので、制限を緩和することが出来ない。

この制限にかかっているのかどうかは、myisamchkコマンドで調べることができる。データベースの格納されているディレクトリに移動して、以下のコマンドを実行する。

# cd ~mysql/openpne
# myisamchk -s c_image.MYI
myisamchk: MyISAM file c_image.MYI
myisamchk: warning: 1 client is using or hasn't closed the table properly
myisamchk: warning: Datafile is almost full, 4294962744 of 4294967294 used
myisamchk: error: got error: 127 when reading datafile at record: 12965
MyISAM-table 'c_image.MYI' is corrupted
Fix it using switch "-r" or "-o"
#

このように、'Datafile is almost full' の警告が表示されたら、ファイルが一杯になっている。これを拡張しない限り、画像ファイルのこれ以上の添付は許されない。

myisamchk -dv で実際のファイルサイズの上限を確認できる。

# myisamchk -dv c_image

MyISAM file:         c_image
Record format:       Packed
Character set:       utf8_general_ci (33)
File-version:        1
Creation time:       2007-10-31 22:23:12
Recover time:        2009-02-06  8:18:34
Status:              checked,optimized keys
Auto increment key:              1  Last value:                 35751
Data records:                33449  Deleted blocks:                 0
Datafile parts:              33449  Deleted data:                   0
Datafile pointer (bytes):        4  Keyfile pointer (bytes):        3
Datafile length:        4294748548  Keyfile length:           1057792
Max datafile length:    4294967294  Max keyfile length:   17179868159
Recordlength:                   46

table description:
Key Start Len Index   Type                     Rec/key         Root  Blocksize
1   2     4   unique  long                           0       274432       1024
2   6     300 multip. varchar prefix BLOB            0      1055744       2048
#

'Max datafile length' が4GBで一杯なのが判る。 これを拡張するのには、mysql で alter table コマンドを発行して、MAX_ROWS, AVG_ROW_LENGHTを変更してやる必要がある。

# mysql -p openpne
Password:
mysql> alter table c_image max_rows=400000;
Query OK, 33449 rows affected (9 min 58.53 sec)
Records: 33449  Duplicates: 0  Warnings: 0

mysql> alter table c_image avg_row_length=200000;
Query OK, 33449 rows affected (10 min 5.41 sec)
Records: 33449  Duplicates: 0  Warnings: 0

mysql> Bye
#

このサイズが妥当かどうかは不明だが、とにかく、ファイルサイズの拡大という目的は達成できる。値については、各サイトの事情に合わせて最適化して欲しい。

# myisamchk -dv c_image

MyISAM file:         c_image
Record format:       Packed
Character set:       utf8_general_ci (33)
File-version:        1
Creation time:       2009-02-06  8:43:00
Recover time:        2009-02-06  8:52:57
Status:              checked,analyzed
Auto increment key:              1  Last value:                 35751
Data records:                33449  Deleted blocks:                 0
Datafile parts:              33449  Deleted data:                   0
Datafile pointer (bytes):        5  Keyfile pointer (bytes):        3
Datafile length:        4294748548  Keyfile length:           1241088
Max datafile length: 1099511627774  Max keyfile length:   17179868159
Recordlength:                   46

table description:
Key Start Len Index   Type                     Rec/key         Root  Blocksize
1   2     4   unique  long                           1        91136       1024
2   6     300 multip. varchar prefix BLOB            1      1239040       2048
#

OpenPNE 2系

OpenPNE 3系

startに戻る。

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information