br3nn4n Posted September 16, 2009 Share Posted September 16, 2009 I have this file name: 0 John's crap.wps I have my coding set up so that it displays a table of files, with a link to /files/(filename) and a delete file link. Obviously, that ' in the name prevents me from linking to the file since php stops outputting after it hits it, and I get a link to "0 John". How can I fix this? Thanks! Link to comment https://forums.phpfreaks.com/topic/174494-need-to-urlencode-butwithout-the-url-encoding-part/ Share on other sites More sharing options...
Handy PHP Posted September 18, 2009 Share Posted September 18, 2009 In your script, where you actually read each filename. Before you do anything with that data, you need to use addslashes The following modified example readdir should work: if ($handle = opendir('.')) { while (false !== ($file = addslashes(readdir($handle)))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); } Basically, it adds a backslash before any single or double quotes in the filename returned before PHP tries to read the information. Good luck, Handy PHP Link to comment https://forums.phpfreaks.com/topic/174494-need-to-urlencode-butwithout-the-url-encoding-part/#findComment-920521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.