Deleting files with special characters...

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
jkashu
Forum Commoner
Posts: 45
Joined: Tue Jan 30, 2007 12:00 pm

Deleting files with special characters...

Post by jkashu »

How can I delete files with special characters with PHP? unlink() just gives me an error saying that the file doesn't exist.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Deleting files with special characters...

Post by Kieran Huggins »

windows or linux?
jkashu
Forum Commoner
Posts: 45
Joined: Tue Jan 30, 2007 12:00 pm

Re: Deleting files with special characters...

Post by jkashu »

linux
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Deleting files with special characters...

Post by Kieran Huggins »

what characters are you having trouble with?
example?
jkashu
Forum Commoner
Posts: 45
Joined: Tue Jan 30, 2007 12:00 pm

Re: Deleting files with special characters...

Post by jkashu »

filenames with % ! " $ & : ? ...lots of crazy things...

The script that was being used on the website was saving pages as the title of the pages, so if the title had a ? or anything in it, it showed up in the filename and gave us problems.

2008:%20%22The%20Year%20of%20the%20River%22%20in%20Cedar%20Rapids21%20Jun%202008,%208:05%20am.php
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Deleting files with special characters...

Post by Kieran Huggins »

out on a limb here, but maybe escapeshellarg() would do the trick?
Post Reply