title: cakephp remove image file from webroot/img folder after deleting record from table
body: <p>I am trying to remove the image file from my webroot/img/uploads folder. However I have succeeded to delete the entries from my mysql db tables but i need to remove the hardcopy as well from the webroot folder... </p>
  
  <p>the following is my controller function for delete photo</p>
  
  <pre><code>  public function delete_photo($id){
          $con['Photo.id'] = $id;
          $the_photo = $this-&gt;Photo-&gt;find('first',array('conditions' =&gt; $con));
          //var_dump($the_photo);
          //echo $the_photo['Photo']['image_name'];
          $this-&gt;Photo-&gt;delete($id);
          function afterDelete($id)
          {
          $file = new File(WWW_ROOT .'/img/uploads/'. $the_photo['Photo']['image_name'],false, 0777);
          if($file-&gt;delete()){
              echo "File deleted";
          }
          else{
              echo "Deletion failed!!";
          }                
          }
          $this-&gt;autoRender = false;
  
    }
  </code></pre>