Cant delete, a single file |
[eluser]rad11[/eluser]
I cant delete a file when using unlink view Code: <?php model Code: public function get_image_name_by_id($id_image){ Controller Code: public function remove_image($id_image){ script delete only in database but not in a folder
[eluser]rad11[/eluser]
Its work but can stay like this? Model Code: public function remove_file($id_image){ Controller Code: public function remove_image($id_image){
[eluser]rad11[/eluser]
Next question is how i can delete checked files from folder? Any idea?
[eluser]CroNiX[/eluser]
You're echoing here instead of returning the value: Code: if ($query->num_rows() > 0) unlink() returns a boolean TRUE upon success, and FALSE upon failure. Maybe you should test that before deleting from your db? Return the status of unlink() from that function, so that you can test it before deleting from the db. Code: public function remove_file($id_image) Then in your controller Code: public function remove_image($id_image){
[eluser]jonez[/eluser]
[quote author="rad11" date="1386963592"] Code: public function remove_file($id_image){ Put the unlink in the if statement, if the record isn't found you'll get an error since row isn't defined. You shouldn't use echo use the output class: http://ellislab.com/codeigniter /user-guide/libraries/output.html The output class adds to a buffer which allows you to do interesting things like automatically minify the content to reduce bandwidth (CI3 has this).
[eluser]anthony_d_mays[/eluser]
It might be worth checking out CodeIgniter's File Helper. See File Helper in User Guide. |
Welcome Guest, Not a member yet? Register Sign In |