Jump to content

[SOLVED] Stripping out bad characters (conflicting with HTTP)


smc

Recommended Posts

Okay,

Basically my CMS, when automatically uploading a picture, renames the picture to the "post's" title with a suffix and then stores it in an images folder.

The problem lies, however, when the title is something like "Timmy's apples are great" because the ' causes problems in the HTTP bar and thus prevents the getting of the image

Is there a PHP function that can help with this problem? Are there any ideas you all have?

Help, like always, is much appreciated :)

Thanks!!
urlencode()

however, it would be an illegal filename - so best to strip it out alltogether.

[code=php:0]$string = preg_replace('#[^a-z0-9\-_\.]#', '', $string);
if (strlen($string) > $x)
{
    // continue..
}[/code]

not forgetting to check the file doesn't exist would help, too.
Works perfectly, no filename errors too :)

Also I've already got the check in place :P I've been working on this stupid picture thing for two days.

To put it in perspective it took me about 3 days to completly do the User system, hook in the databases, allow user editing, posting stories, deleting stories, editing stories, etc. etc. etc.

Stupid pictures :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.