gdfhghjdfghgfhf Posted June 15, 2013 Share Posted June 15, 2013 I have a FTP shared with friends where we upload underground music albums and then we use the links to share the downloads in a music forum. Problem is that the album names are in french so there is a lot of special characters in the nameSo the URL looks like *http://www.mydomain.com/downloads/Some Band - En français avec des caractères spéciaux (2013) [7'' EP].zip*For me it works perfectly and i can download the file by using this URL but i have read everywhere that special chars are bad in URL.Is there any reason why i MUST remove the special characters or encode the URL ?Is everyone able to access an URL with special characters or some older browsers won't be able to download the file ?I really don't care about SEO or anything else. I just want the download links to work for everyone.Since the files are uploaded through FTP i can't use PHP to remove the special chars with regex so i really don't know what to do. Quote Link to comment https://forums.phpfreaks.com/topic/279193-special-characters-in-url/ Share on other sites More sharing options...
requinix Posted June 15, 2013 Share Posted June 15, 2013 You generally don't need to because browsers will do it for you, but that's only because websites don't always do it themselves. So you should try to. $file = "Some Band - En français avec des caractères spéciaux (2013) [7'' EP].zip"; echo "<a href='http://www.mydomain.com/downloads/" . htmlentities(urlencode($file)) . "'>Download</a>";urlencode() because you're putting something into a URL, then htmlentities() because you're putting that into HTML. Quote Link to comment https://forums.phpfreaks.com/topic/279193-special-characters-in-url/#findComment-1436092 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.