CodeIgniter Forums
delete_files function does not work me - 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: delete_files function does not work me (/showthread.php?tid=65165)



delete_files function does not work me - nkhan - 05-09-2016

Hello, Everybody

I am using Codeigniter 3.6 .

I cant understand what wrong i have done .
 


PHP Code:
public function delete_photo(){

  
$this->load->helper('file');

  
delete_files(base_url("uploads/".$_POST['old_photo'])); 



Please guide me 

Thanks


RE: delete_files function does not work me - arma7x - 05-09-2016

(05-09-2016, 12:59 PM)nkhan Wrote: Hello, Everybody

I am using Codeigniter 3.6 .

I cant understand what wrong i have done .
 


PHP Code:
public function delete_photo(){

 
 $this->load->helper('file');

 
 delete_files(base_url("uploads/".$_POST['old_photo'])); 



Please guide me 

Thanks
delete_files() deletes ALL files contained in the suppliedpath. To delete single file use/refer this link http://php.net/manual/en/function.unlink.php


RE: delete_files function does not work me - Narf - 05-09-2016

1. CodeIgniter 3.6 doesn't exist.
2. Files are deleted from file-system paths, not from URLs.


RE: delete_files function does not work me - ivantcholakov - 05-10-2016

https://en.wikipedia.org/wiki/Directory_traversal_attack

Also, I think, in $_POST it would be safer if it is possible you to identify the file to be deleted with a database id than with the file name directly.


RE: delete_files function does not work me - nkhan - 05-10-2016

(05-10-2016, 07:06 AM)ivantcholakov Wrote: https://en.wikipedia.org/wiki/Directory_traversal_attack

Also, I think, in $_POST it would be safer if it is possible you to identify the file to be deleted with a database id than with the file name directly.

Hi @ivantcholakov

Actually i want to know is there any  predefined function for delete a single file(it may be a pdf / doc/ image) in CI is exist or not. I know unlink() 

which is used to delete the file but it is core function of PHP. 

Please let me know.


RE: delete_files function does not work me - Narf - 05-10-2016

(05-10-2016, 08:44 AM)nkhan Wrote:
(05-10-2016, 07:06 AM)ivantcholakov Wrote: https://en.wikipedia.org/wiki/Directory_traversal_attack

Also, I think, in $_POST it would be safer if it is possible you to identify the file to be deleted with a database id than with the file name directly.

Hi @ivantcholakov

Actually i want to know is there any  predefined function for delete a single file(it may be a pdf / doc/ image) in CI is exist or not. I know unlink() 

which is used to delete the file but it is core function of PHP. 

Please let me know.

And that unlink() is a native PHP function makes it bad somehow?
CodeIgniter doesn't have a single-file-delete function exactly because PHP already provides one out of the box.