Now everything is working like i expected.

To keep the file in {IMAGE}... and delete the file in {APP}... im
using the afterSave callback in my model:

        function afterSave() {

                if (!empty($this->data[$this->name]['logo'])) {

                        $baseDir        = ROOT . DS . APP_DIR . DS . 'uploads' 
. DS;
                        $path           = $baseDir . 
$this->data[$this->name]['relativePath'];

                        @unlink($path);

                }

                return true;

        }

Now in my add action im assigning a uniq name to the file like this:

        function add() {

                if (!empty($this->data)) {

                        $this->Test->create();

                        $this->data['Test']['class']            = 'tests';

                        $extension = end(explode('.', 
$this->data['Test']['logo']
['name']));
                        $filename = String::uuid() . '.' . low($extension);

                        $this->data['Test']['filename']         =  $filename;

                        if ($this->Test->save($this->data)) {

                                $this->Session->setFlash(__('The Test has been 
saved', true));
                                $this->redirect(array('action'=>'index'));
                        } else {
                                $this->Session->setFlash(__('The Test could not 
be saved. Please,
try again.', true));
                        }
                }

        }


my model actas is:


        var $actsAs = array('ImageUpload' => array(
                                        'fileField'             => 'logo',
                                        'allowedMime'           => 
array('image/jpeg', 'image/gif', 'image/png',
'image/bmp'),
                                        'allowedExt'            => 
array('jpeg', 'jpg', 'gif', 'png', 'bmp'),
                                        'baseDir'                       => 
'{APP}uploads{DS}',
                                        'dirFormat'             => '{$class}',
                                        'overwriteExisting' => false,
                                        'versions'                      => 
array('small' => array(
                                                                                
                        'vBaseDir' =>'{IMAGES}',
                                                                                
                        'vDirFormat' => '{$class}{DS}',
                                                                                
                        'vFileFormat' => '{$filename}',
                                                                                
                        'callback' => array('resize', 75, 75)
                                                                                
                )
                                                                                
        )
                                        )
                                );

Now im going to try to edit and delete a record with a single image
filed and see what happens.


Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to