Re: how to use the formatFileName option of the Uploader plugin of Miles Johnson?
Thank you Miles!
You did a great job with Upolader.
On 8 jan, 23:22, Miles J <mileswjohn...@gmail.com> wrote:
> I noticed my docs are a bit out of date, updated them.
>
> On Jan 7, 12:02 pm, franck <noreag...@gmail.com> wrote:
>
>
>
>
>
>
>
> > 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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home