Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
delete image "file" in server from controller
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chris  
View profile  
 More options Nov 11 2012, 7:24 pm
From: Chris <chris...@yahoo.com>
Date: Sun, 11 Nov 2012 16:24:25 -0800 (PST)
Local: Sun, Nov 11 2012 7:24 pm
Subject: delete image "file" in server from controller

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_se cret'].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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris  
View profile  
 More options Nov 12 2012, 9:51 am
From: Chris <chris...@yahoo.com>
Date: Mon, 12 Nov 2012 06:51:02 -0800 (PST)
Local: Mon, Nov 12 2012 9:51 am
Subject: Re: delete image "file" in server from controller

no one,...???


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bs28723  
View profile  
 More options Nov 12 2012, 10:19 am
From: bs28723 <bill.sto...@boosterwebsolutions.com>
Date: Mon, 12 Nov 2012 07:18:43 -0800 (PST)
Local: Mon, Nov 12 2012 10:18 am
Subject: Re: delete image "file" in server from controller

You did not specify which line is getting the error. I am guessing one
of the File lines????

Have you tried...

  $file = new File(WWW_ROOT
."/img/group-banners/banner/".$group['Group']['id']."-".$group['Group']['ph oto_secret'].".jpg");

On 11/12/2012 9:51 AM, chris...@yahoo.com [via CakePHP] wrote:

--
View this message in context: http://cakephp.1045679.n5.nabble.com/delete-image-file-in-server-from...
Sent from the CakePHP mailing list archive at Nabble.com.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tilen Majerle  
View profile  
 More options Nov 12 2012, 10:40 am
From: Tilen Majerle <tilen.maje...@gmail.com>
Date: Mon, 12 Nov 2012 16:38:54 +0100
Local: Mon, Nov 12 2012 10:38 am
Subject: Re: delete image "file" in server from controller

$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 <chris...@yahoo.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris  
View profile  
 More options Nov 14 2012, 1:30 am
From: Chris <chris...@yahoo.com>
Date: Tue, 13 Nov 2012 22:30:08 -0800 (PST)
Local: Wed, Nov 14 2012 1:30 am
Subject: Re: delete image "file" in server from controller

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 ,... !!!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris  
View profile  
 More options Nov 14 2012, 1:32 am
From: Chris <chris...@yahoo.com>
Date: Tue, 13 Nov 2012 22:32:54 -0800 (PST)
Local: Wed, Nov 14 2012 1:32 am
Subject: Re: delete image "file" in server from controller

thank you bs28723,... it solved,...
check the reply on this post,...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »