Stop user from deleting a set file name not working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Stop user from deleting a set file name not working (/showthread.php?tid=63237) |
Stop user from deleting a set file name not working - wolfgang1983 - 10-10-2015 I have a file in two locations called no_image.jpg When user try's to delete the image I would like to be able to stop the user from deleting just that image. But for some reason the image still gets delete How can I make it stop deleting image if file is no_image.png PHP Code: public function delete() { Any examples on how to solve it would be great. RE: Stop user from deleting a set file name not working - JayAdra - 10-10-2015 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 RE: Stop user from deleting a set file name not working - wolfgang1983 - 10-10-2015 (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. 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() { RE: Stop user from deleting a set file name not working - wolfgang1983 - 10-10-2015 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() { |