thank you for your reply Ma.Jerle 
this is what I got,... in case anyone wonder,... 
I took delete images from server to a Model Group when the Group is 
deleted,... 

  function getOriginalFile($id, $secret, $create = null, $chmod = null)
  {
    return new File(WWW_ROOT . 'group-banners' . DS . 'original' . DS . $id 
. '-' . $secret . '.jpg', $create, $chmod);
  }
 
  function getSquareFile($id, $secret, $create = null, $chmod = null)
  {
    return new File(WWW_ROOT . 'group-banners' . DS . 'square' . DS . $id . 
'-' . $secret . '.jpg', $create, $chmod);
  }
   
  function getBannerFile($id, $secret, $create = null, $chmod = null)
  {
    return new File(WWW_ROOT . 'group-banners' . DS . 'banner' . DS . $id . 
'-' . $secret . '.jpg', $create, $chmod);
  }
   
  function getBuddyFile($id, $secret, $create = null, $chmod = null)
  {
    return new File(WWW_ROOT . 'group-banners' . DS . 'buddy' . DS . $id . 
'-' . $secret . '.jpg', $create, $chmod);
  }
  

  function beforeDelete()
   {

     $this->loadModels('Group');

     $photo = $this->findById($this->id());
     $this->secret = $photo['Group']['photo_secret'];
     
     foreach(array($this->getOriginalFile($this->id(), $this->secret), 
$this->getSquareFile($this->id(), $this->secret), 
$this->getBannerFile($this->id(), $this->secret), 
$this->getBuddyFile($this->id(), $this->secret)) as $file)
     {
       if($file->exists())
         $file->delete();
     }
     
     return true;
   }

and delete images to replace and edit on new upload to a controller,... 

 
  function edit_upload($id)
  {
    $this->authorize();

    $group_id = $id;

    $user = $this->User->findById($this->user['id']);

      if(!$this->authorize($user['User']['id']))
        return;

    
    if($group = $this->Group->findById($id))
    {
 $photo = ($group['Group']['id']."-".$group['Group']['photo_secret']);

     $file = new File(WWW_ROOT . 'group-banners' . DS . 'banner' . DS . 
$photo . '.jpg', false, 0777);

        if($file->exists())
          $file->delete();

     $file = new File(WWW_ROOT . 'group-banners' . DS . 'original' . DS . 
$photo . '.jpg', false, 0777);

        if($file->exists())
          $file->delete();

     $file = new File(WWW_ROOT . 'group-banners' . DS . 'buddy' . DS . 
$photo . '.jpg', false, 0777);

        if($file->exists())
          $file->delete();

     $file = new File(WWW_ROOT . 'group-banners' . DS . 'square' . DS . 
$photo . '.jpg', false, 0777);

        if($file->exists())
          $file->delete();
    }

this what works for me,... 

thank you guys all ,... !!! 




On Monday, November 12, 2012 7:40:02 AM UTC-8, MaJerle.Eu wrote:
>
> $group['Group']['id']-$group['Group']['photo_secret'] here is problem...
>
>
> try this
> $file = new File(WWW_ROOT ."/img/group-banners/banner/" . 
> $group['Group']['id'] 
> . "-" . $group['Group']['photo_secret'].jpg");
>
> --
> Lep pozdrav, Tilen Majerle
> http://majerle.eu
>
>
>
> 2012/11/12 Chris <[email protected] <javascript:>>
>
>> no one,...??? 
>>
>>
>> On Sunday, November 11, 2012 4:24:25 PM UTC-8, Chris wrote:
>>>
>>>
>>> hi guys,... can someone help me please,... 
>>>
>>> I got image files in server: 
>>>
>>> /img/group-banners/original/**39-afgmeq4hbsq7fmx2fywc.jpg
>>> /img/group-banners/banner/39-**afgmeq4hbsq7fmx2fywc.jpg 
>>>
>>> where "39" is a asigned as group id as unique id for a file while its 
>>> uploading, and "afgmeq4hbsq7fmx2fywc" is set to 
>>> $group['Group']['photo_secret'**]
>>>
>>> and I want to delete these files from controller on delete function,... 
>>> when I'm deleting group 
>>>
>>>       if($this->Group->delete($**group['Group']['id']))
>>>       {
>>>        $file = new File(WWW_ROOT ."/img/group-banners/original/**
>>> $group['Group']['id']-$group['**Group']['photo_secret'].jpg");
>>>        $file = new File(WWW_ROOT ."/img/group-banners/banner/$**
>>> group['Group']['id']-$group['**Group']['photo_secret'].jpg");
>>>        if($file->exists())
>>>        $file->delete();
>>>
>>> I'm getting an error: 
>>> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, 
>>> expecting T_STRING or T_VARIABLE or T_NUM_STRING 
>>>
>>> how can I do this,...? 
>>>
>>> thanks in advance 
>>> chris
>>>
>>>  -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> [email protected] <javascript:>.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>  
>>  
>>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to