よくアップロード処理の開発でハマるので、FileUploadフィルターについて調べてみた。
maple.ini
[FileUpload]
name = file_csv ← input type=file属性のname名称。実際のテンプレートに合わせる
allow_extension = "true" ← configテーブルの許す拡張子の一覧から拡張子チェックを行うかどうかのフラグ
maxsize = "" ← 最大ファイル容量=無制限
stopper = "false" ← 無指定だと trueになる。
true:FileUploadフィルタ内で、MIME-Typeチェック、拡張子チェック等行う。チェックエラーの場合、画面に出るエラーメッセージは一律「ファイルアップロードに失敗しました」
false:ファイルの最大ファイル容量チェック、ルームの合計最大ファイル容量チェックのみ行う。
stopper = "true"チェック
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L446
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L458
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L468
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L478
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L495-L499
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L507-L511
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L526-L530
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L546-L550
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L565-L569
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L584-L588
stopper = "false"でもチェック
ファイルの最大ファイル容量チェック
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L659-L664
ルームの合計最大ファイル容量チェック
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L677-L685
参考
http://ncwiki.commonsnet.org/develop/index.php?Javascriptリファレンス#y7f39307
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php
おまけ allow_attachment
[FileUpload]
;allow_attachment = _ALLOW_ATTACHMENT_IMAGE
基本、指定しなくて良い。
指定しないと、allow_attachment = _ALLOW_ATTACHMENT_ALL として扱われる。
maple.iniで allow_attachment を設定すると、ここに入る。
https://github.com/netcommons/NetCommons2/blob/e89bfb7c3e9253c07c34ac16999b44428473b51e/html/maple/filter/Filter_FileUpload.class.php#L153-L156
//configの権限でアップロード可能かどうかを取得
$allow_attachment_flag = $session->getParameter("_allow_attachment_flag");
//maple.iniで allow_attachment の定数取得
$attributes_allow_attachment_flag = $this->constantDef($attributes["allow_attachment"]);
何等かエラー有り(PHP自体が感知するエラーは発生していない場合)の時
- configのアップロード権限が、
_ALLOW_ATTACHMENT_IMAGE
-
maple.ini
の allow_attachment_ALLOW_ATTACHMENT_ALL
だとエラーにしてた。
理由はよくわからんのです。
ではでは。