Hi guys,
I am a real newbie in cakephp, I used to play with Symfony.
I am trying to use the Uploader plugin of Miles Johnson to upload some
pictures and attach them to a table, it sounds very good.
I have test it on a simple table named Photos, which has two varchar
fields : 'title' and 'uploadPath'.
Everything is ok (after one day), ie I can upload pictures in a
specific folders and attach it to the table. But I still can't make
the formatFileName option work.
As described in his tutorial, my Model/Photo.php looks like :
public $actsAs = array(
'Uploader.Attachment' => array(
'fileName' => array(
'name' => 'formatFilename', // it doesn't
work
'baseDir' => '',
'uploadDir' => 'upload', // it works
'dbColumn' => 'uploadPath', // it works
.....);
and I created the function formatFileName in the same file (Model/
Photo.php):
public function formatFilename($name, $field, $file) {
return md5($name);
}
And in my PhotosController, I have the function to add the pictures :
public function add() {
if($this->request->is('post')) {
$this->Uploader = new Uploader();
if ($this->Photo->save($this->request->data)) {
// Upload successful
$this->Session->setFlash('Upload photo
succeded');
} else {
$this->Session->setFlash('Unable to upload');
}
}
}
But it doesn't work, all my uploaded files are called
formatFileName.jpg....
Do you have any idea of what I am doing wrong?
Regards,
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php