smc Posted January 30, 2007 Share Posted January 30, 2007 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 imageIs there a PHP function that can help with this problem? Are there any ideas you all have?Help, like always, is much appreciated :)Thanks!! Link to comment https://forums.phpfreaks.com/topic/36269-solved-stripping-out-bad-characters-conflicting-with-http/ Share on other sites More sharing options...
effigy Posted January 30, 2007 Share Posted January 30, 2007 [url=http://us2.php.net/urlencode]urlencode[/url]. Link to comment https://forums.phpfreaks.com/topic/36269-solved-stripping-out-bad-characters-conflicting-with-http/#findComment-172443 Share on other sites More sharing options...
smc Posted January 30, 2007 Author Share Posted January 30, 2007 That is why I love PHP but also why I feel like an idiot when it's a simple function :PThanks :) Link to comment https://forums.phpfreaks.com/topic/36269-solved-stripping-out-bad-characters-conflicting-with-http/#findComment-172444 Share on other sites More sharing options...
Jenk Posted January 30, 2007 Share Posted January 30, 2007 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. Link to comment https://forums.phpfreaks.com/topic/36269-solved-stripping-out-bad-characters-conflicting-with-http/#findComment-172445 Share on other sites More sharing options...
smc Posted January 30, 2007 Author Share Posted January 30, 2007 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 :( Link to comment https://forums.phpfreaks.com/topic/36269-solved-stripping-out-bad-characters-conflicting-with-http/#findComment-172450 Share on other sites More sharing options...
Jenk Posted January 30, 2007 Share Posted January 30, 2007 Just be warned when you upload it off of your windows machine, onto a *nix box it will be an illegal filename. Link to comment https://forums.phpfreaks.com/topic/36269-solved-stripping-out-bad-characters-conflicting-with-http/#findComment-172504 Share on other sites More sharing options...
smc Posted January 30, 2007 Author Share Posted January 30, 2007 I already tried with an apostrophe, uploading from a windows to a unix and it was fine :-\ Link to comment https://forums.phpfreaks.com/topic/36269-solved-stripping-out-bad-characters-conflicting-with-http/#findComment-172508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.