Welcome Guest, Not a member yet? Register   Sign In
Delete files from directory
#1

[eluser]Zeeshan Rasool[/eluser]
Hi, anyone here that tell me about this prob.This is function in model i want to delete uploaded video file from folder './public/videos'

$this->db->where('video_id', $video_id);
$this->db->select(trim('video_path'));
$query = $this->db->get('help_video');
foreach($query->result() as $item)
{
$old_video_path=($item->video_path);
}
delete_files('./public/videos/'.$old_video_path);
$this->db->where('video_id', $video_id);
$this->db->delete('help_video');


Problem:the information such as video title and path is deleted from DB but video file is still in directory. What shud me do!
.....thnx in Adv.
#2

[eluser]Zeeshan Rasool[/eluser]
I got it!

unlink(’./public/videos/’.$old_video_path); works fine.

i have used that code instead of using delete_files

thnx.
#3

[eluser]flojon[/eluser]
Demanding people to help you isn't very polite and will only turn people away from helping you.
Also I suggest the next time you need help you use subject that describes your problem

Regards,
Jonas
#4

[eluser]Référencement Google[/eluser]
Agreed with Flojon. And also don't worry, we see your posts and don't need to give them an "urgence", CI community is very helpful and will help you really quickly without you have to ask in an emergency.

Also please as already suggested yesterday to you, when you post code, use the Code tags to wrap your code in, it's unreadable otherwise !
#5

[eluser]Zeeshan Rasool[/eluser]
ok guys sorry! next time it will not happen again.
#6

[eluser]Unknown[/eluser]
wooowww... this is really what i've been lookin for.
my 1 hour work with delete_files function now solved! thx so much
#7

[eluser]dimazarno[/eluser]
nice one.., it really helps me

thx
#8

[eluser]BrianDHall[/eluser]
For extra safety (and to avoid errors) you might want to take a look at "is_file()" native PHP function.
#9

[eluser]InsiteFX[/eluser]
Also please use code tags when submitting code, it's easier to read.

Enjoy
InsiteFX
#10

[eluser]Thug_Angel[/eluser]
wow...
spent the last hour trying to figure out if i did something wrong when using delete_files();
when "unlink" function was there all along Sad

anyone knows what the reason might be for
Code:
delete_files('./public/videos/'.$old_video_path);
not working?
i even try loading helper file directly in my function.




Theme © iAndrew 2016 - Forum software by © MyBB