Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
controller part
C#
public function delete1($id) {

      $this->Form->id = $id;
   $this->Form->delete($this->request->data('Form.image'));
  $this->Session->setFlash('Image  remove successfully');
 }

in edit.ctp

XML
echo  $this->Html->image('/app/webroot/images/small/thumb_' . $ceck['Form']['image'],array('alt'=>'apple','width'=>'70px','height'=>'50px')) ;
   echo "<br>";
   echo $this->Html->link($this->Html->image('delete.png', array('alt' => 'Delete','title' => 'Delete')), array( 'controller' => 'forms','action' => 'delete1',$ceck['Form']['id'] ), array( 'escape' => false, 'confirm' => 'Are you sure you want to delete?' ));
  }
Posted
Updated 14-Jan-15 2:33am
v2

1 solution

in controller part.It works perfectly
public function deleteimage($id)
{

$data = $this->Form->findById($id);

echo $name = $data['Form']['image'];
unlink(DIR_SELLPRODUCTL . $data['Form']['image']);

unlink(DIR_SELLPRODUCTM .'thumb_'. $data['Form']['image']);
if ($this->Form->updateAll(array('image' =>NULL),array('id' => $id))) {

$this->Session->setFlash(
__('The Image has been deleted.')
);
return $this->redirect(array('action' => 'edit',$id));
}
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900