私はCakePHP2.1.1とMilesJohnsonのUploaderPluginv3.5を使用しています。
FileValidationの動作をアンロードしようとすると問題が発生すると思いますが、かなりうまく機能しています。
Uploader.Attachment
動作との両方を設定しましたUploader.FileValidator
(質問の下部を参照)。
コールバックで、別のロケールの翻訳済みフィールドを追加するために、もう一度 afterSave
保存する必要があります。Post
もう一度保存すると、FileValidation
動作にエラーが発生するようです。エラーが発生します:
failed to open stream: No such file or directory [APP/Plugin/Uploader/Model/Behavior/FileValidationBehavior.php, line 296]
どういうわけか、動作はtmpファイルを再度探しています。動作をまったく
定義しないと、すべてうまくいきます。FileValidation
だから私は、通常の間にそれが仕事をした後save()
、私が2番目に行く直前に、その振る舞いを無効にすることを考えましたsave()
。したがって、私
はafterSave($created)
$this->Behaviors->unload('FileValidation');
$this->save($data);
エラーは消えますが、4つの警告が返されます。
Warning (512): Could not find validation handler maxWidth for file [CORE/Cake/Model/Model.php, line 3155]
Warning (512): Could not find validation handler maxHeight for file [CORE/Cake/Model/Model.php, line 3155]
Warning (512): Could not find validation handler filesize for file [CORE/Cake/Model/Model.php, line 3155]
Warning (512): Could not find validation handler required for file [CORE/Cake/Model/Model.php, line 3155]
私も試し$this->Behaviors->disable('FileValidation')
ましたが、役に立ちませんでした。これは動作のバグ(それ自体を適切にアンロードしない)ですか、それともアンロードを適切に処理していませんか?
よろしく、バート
動作の設定:
public $actsAs = array('Uploader.Attachment' => array(
'file' => array(
'name' => 'uniqueFilename', // Name of the function to use to format filenames
'baseDir' => APP, // See UploaderComponent::$baseDir
'uploadDir' => 'webroot/img/upload/', // See UploaderComponent::$uploadDir
'dbColumn' => 'uploadPath', // The database column name to save the path to
'importFrom' => '', // Path or URL to import file
'defaultPath' => '', // Default file path if no upload present
'maxNameLength' => 30, // Max file name length
'overwrite' => false, // Overwrite file with same name if it exists
'stopSave' => true, // Stop the model save() if upload fails
'transforms' => array(), // What transformations to do on images: scale, resize, etc
's3' => array(), // Array of Amazon S3 settings
'metaColumns' => array( // Mapping of meta data to database fields
'ext' => 'ext',
'type' => 'type',
'size' => 'size',
'group' => 'group',
'width' => 'width',
'height' => 'height',
'filesize' => 'size',
'name'=>'name'
)
)
),
'Uploader.FileValidation' => array(
'file' => array(
'maxWidth' => array(
'value' => 1000,
'error' => 'Image too wide. Max 1000px'
),
'maxHeight' => array(
'value' => 1000,
'error' => 'Image too high. Max 1000px'
),
'extension' => array(
'value' => array('gif', 'jpg', 'png', 'jpeg'),
'error' => 'Mimetype incorrect',
),
'filesize' => array(
'value' => 1048576,
'error' => 'Filesize too high. Max 1 MB'
)
)
)
);