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

(This post was last modified: 10-10-2015, 12:59 AM by wolfgang1983.)

(10-10-2015, 12:29 AM)JayAdra Wrote: It looks like your "validation" is just checking if the variable $no_image_check is set, which it is on the previous line.

What you want to do is check if the actual file exists:
http://php.net/manual/en/function.file-exists.php

I have check boxes below each image though and user needs to have that check box checked before delete but need to make sure does not delete the no_image.jpg.

I am also not sure if I have my json message in correct places.


PHP Code:
    public function delete() {

        $json = array();

        if (!$json) {

            foreach ($this->input->post('path') as $path) {
                $no_image_check $this->config->item('image_path') . 'catalog/no_image.jpg';

                if (isset($no_image_check)) {
                    
                    $json
['error'] = 'You canot remove this image';

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

                        if (file_exists($this->config->item('image_path') . $path)) {
                            delete_files($this->config->item('image_path') . $path);
                            delete_files($this->config->item('image_cache_path') . $path);
                        

                        continue;

                        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)) {

                        delete_files($this->config->item('image_path') . $path);
                        delete_files($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));

    


Attached Files Thumbnail(s)
   
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, 12:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB