• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
delete_files function does not work me

#1
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
Reply

#2
(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
Keep calm.
Reply

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

#4
https://en.wikipedia.org/wiki/Directory_...sal_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.
Reply

#5
(05-10-2016, 07:06 AM)ivantcholakov Wrote: https://en.wikipedia.org/wiki/Directory_...sal_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.
Reply

#6
(05-10-2016, 08:44 AM)nkhan Wrote:
(05-10-2016, 07:06 AM)ivantcholakov Wrote: https://en.wikipedia.org/wiki/Directory_...sal_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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.