-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
I’ve a model that I’ve added the file upload plugin to as a behavior. My model is set up as follows:
<?php
class Promoter extends AppModel {
public $name = 'Promoter';
public $actsAs = array(
'Containable',
'FileUpload.FileUpload' => array(
'allowedTypes' => array(
'gif' => array(
'image/gif'
),
'jpg' => array(
'image/jpeg',
'image/pjpeg'
),
'png' => array(
'image/png'
)
),
'fields' => array(
'name' => 'image_filename',
'type' => 'image_type',
'size' => 'image_size'
),
'fileNameFunction' => 'sanitizeFileName',
'required' => false
)
);
public function sanitizeFileName($filename) {
$imagesDir = 'promoters';
if (!is_dir($imagesDir)) {
mkdir($imagesDir);
chmod($imagesDir, 0755);
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
return $imagesDir . DS . $this->data[$this->alias]['id'] . '.' . $extension;
}
}As you can see, required is set to false. The Promoter model is saved successfully if I also include an image for upload (the values are set in the database row, and the actual image is uploaded to the file system); however, if I don’t select an image to upload, then the database record is not updated despite getting a flash message saying record has been updated.
Any one able to see what the problem is? Have I configured something incorrectly, or is this just because this is the in-development branch and it’s not been addressed yet?
Metadata
Metadata
Assignees
Labels
No labels