Click to See Complete Forum and Search --> : Deleting Files.


iceafreak99
06-19-2003, 09:35 AM
I making a Shopping site, and I have a admin panel I'm making that makes the categories, and items and it all works good, except for delete.

Say I have a category called Snowmobile in qoutes are thr urls, and it was set up as follows..

Snowmobile (site.com/shop/Snowmobile/)
Snowmobile > Oils & Lubes (site.com/shop/Snowmobile/Oils_Lubes/)
Snowmobile > Oils & Lubes > 2 Cycle (site.com/shop/Snowmobile/Oils_Lubes/2_Cycle/)
Snowmobile > Oils & Lubes > 4 Cycle (site.com/shop/Snowmobile/Oils_Lubes/4_Cycle/)
Snowmobile > Tracks (site.com/shop/Snowmobile/Tracks/)
Snowmobile > Riding Gear (site.com/shop/Snowmobile/Riding_Gear/)
Snowmobile > Riding Gear > Gloves (site.com/shop/Snowmobile/Riding Gear/Gloves)
Snowmobile > Riding Gear > Gloves > Thor (site.com/shop/Snowmobile/Riding Gear/Gloves/Thor)

Now each of those directories has a file I made called index.php

What If I wanted to delete Snowmobile directory and everything in it, see I can't just rmdir I need to go in there delete all the files and directories first.

Any ideas?

pyro
06-19-2003, 10:42 AM
Yeah, I think you are going to have to loop through the files in the directory and delete them first. You will also have to loop through sub-directorys and delete the files inside them. You use unlink() (http://us2.php.net/manual/en/function.unlink.php) to delete files.

pyro
06-19-2003, 10:45 AM
Look through some of the user submitted comments for rmdir() (http://us2.php.net/manual/en/function.rmdir.php). One is probably going to be what you need....

iceafreak99
06-19-2003, 10:47 AM
$file = $path . $it[0];
exec("rm -rf $file");


Worked Awsome, all the time I could of saved if I just would of asked.