Using the Upload Plugin. I want to upload files in a foreign_key folder to "guarantee" random, since it doesn't appear to have any check for an existing file before overwriting a file(s).
I'd like a file to upload to something like:
/webroot/uploads/02/88/06/4f93676e-347c-4e0c-8e6c-0a3cadcd7f7c/my_photo.jpg
When I set 'pathMethod'=>'random'
, I get the 3 random number (between 0-100) folders, but I don't get the primary key folder.
Or, if I set 'pathMethod'=>'primaryKey', I get the primary key folder, but not the random numbers.
In the Upload behavior of the plugin, there's an uploadSettings
function (not sure if that's what it's for), but when I try to run it via my controller, it doesn't do anything:
//ArticleDatasController
$this->Upload->uploadSettings('Upload', 'photo', array('path'=> '{ROOT}webroot{DS}uploads{DS}test{DS}ArticleData{DS}{field}'));
if($this->Upload->save($this->request->data)) {
Here's my Upload model's $actsAs:
//Upload model
public $actsAs = array(
'Upload.Upload' => array(
'photo' => array(
'thumbnailSizes' => array(
'xvga' => '1024x768',
'vga' => '640x480',
'thumb' => '80x80',
),
'thumbnailMethod' => 'php',
'thumbnailQuality' => '80',
'pathMethod'=>'random',
'path' => '{ROOT}webroot{DS}uploads{DS}{field}{DS}',
'maxSize' => '5242880', //5MB
'mimetypes' => array('image/jpeg', 'image/png', 'image/gif', 'image/bmp'),
'extensions' => array('jpg', 'gif', 'png', 'bmp'),
),
)
);