PHP FILES

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
truepal20032001
Forum Commoner
Posts: 27
Joined: Mon Jun 25, 2007 8:28 pm

PHP FILES

Post by truepal20032001 »

How would i say in php to delete all the files with the same filetype, like... delete all JPGs from this folder... but only the jpgs...
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: PHP FILES

Post by jaoudestudios »

If you are using php5, then you can use scandir to scan the directory, then check the extension, if the extension matches what you want, then unlink the file.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP FILES

Post by VladSun »

I would prefer using glob() in this case.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: PHP FILES

Post by jaoudestudios »

Cheers VladSun. I did not know about that, I have just looked it up, very useful :)
truepal20032001
Forum Commoner
Posts: 27
Joined: Mon Jun 25, 2007 8:28 pm

Re: PHP FILES

Post by truepal20032001 »

Thankyou very much!
Post Reply