milesj/cake-uploader — Issue #36: Missing filename on transform
Author: bradmaxs
Created: 2012-01-31 03:00:06+00:00
State: open

Hey Miles,

Thanks for the awesome plugin.

I am having a slight problem when I try and transform the images. It seems that the first file (which I save in name_original) keeps the filename but the transforms, although they do get saved into the database, the name is then gone and it just saves the append without the new formated name.

Here is the model:

array(
'file' => array(
'name'	=> 'formatFileName',	// Name of the function to use to format filenames
'uploadDir'	=> 'files/',	// See UploaderComponent::$uploadDir
'dbColumn'	=> 'name_original',	// 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'	=> 90,	// Max file name length
'overwrite'	=> true,	// Overwrite file with same name if it exists
'stopSave'	=> true,	// Stop the model save() if upload fails
'transforms' => array(
array('method' => 'resize', 'width' => 800, 'append' => 'resized', 'dbColumn' => 'name_resize'),
array('method' => 'crop', 'width' => 125, 'height' => 83, 'append' => 'thumb', 'dbColumn' => 'name_thumb')
),
'metaColumns'	=> array(
'ext' => '',
'type' => 'type',
'size' => 'size',
'group' => '',
'width' => '',
'height' => '',
'filesize' => ''
)
)
),
'Uploader.FileValidation' => array(
'file' => array(
'extension' => array(
'value' => array('gif', 'jpg', 'png', 'jpeg'),
'error' => 'You can only upload gif, jpg and png files.',
),
'filesize' => array(
'value' => 5242880,
'error' => 'File must be under 5MB.'
),
'required' => array(
'value' => true,
'error' => 'You must attach a file before uploading.'
)
)
)
);

bootstrap.php:

function formatFileName($name, $field, $file) {
return md5($name . date('G:i:s'));
}

and the records from the db:

(50, 'Gallery', 12, '/files/a227b31fbd6a1405dae4edc7d56e225a.jpg', '/files/resized.jpg', '/files/thumb.jpg', 'image/jpeg', 48661, '', '2012-01-30 21:50:39', '2012-01-30 21:50:39'),
(49, 'Gallery', 12, '/files/dd3d0c0ff513b956f82de6757b29651b.jpg', '/files/resized.jpg', '/files/thumb.jpg', 'image/jpeg', 48661, '', '2012-01-30 21:48:21', '2012-01-30 21:48:21');

as you can see the 5th & 6th fields seem to have dropped the original filename.

I am using 3.1.4 btw.

Thank you Miles.

Brad