Welcome Guest, Not a member yet? Register   Sign In
Stop user from deleting a set file name not working
#4

After some more thinking about it I have got it all most working now.

In my foreach loop I have done a check like below.

if ($this->config->item('image_path') . $path == $no_image_check) {



PHP Code:
   public function delete() {
 
       $json = array();

 
       if (!$json) {

 
           $no_image_check $this->config->item('image_path') . 'catalog/no_image.jpg';

 
           foreach ($this->input->post('path') as $path) {

 
               if ($this->config->item('image_path') . $path == $no_image_check) {

 
                   $json['error'] = 'Your Selected File Can\'t be removed!';

 
               } else {

 
                   if (is_dir($this->config->item('image_path') . $path)) {

 
                       rmdir($this->config->item('image_path') . $path);
 
                       rmdir($this->config->item('image_cache_path') . $path);

 
                       $json['success'] = 'Your Selected Folder Has Been Removed!';

 
                   } elseif (is_file($this->config->item('image_path') . $path)) {

 
                       unlink($this->config->item('image_path') . $path);
 
                       unlink($this->config->item('image_cache_path') . $path);

 
                       $json['success'] = 'Your Selected File Has Been Removed!';

 
                   }
 
               }
 
               
            
}
 
           
        
}

 
   $this->output->set_content_type('Content-Type: application/json');
 
  $this->output->set_output(json_encode($json));


There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Stop user from deleting a set file name not working - by wolfgang1983 - 10-10-2015, 01:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB