Jump to content

Need to urlencode() but...without the url encoding part.


br3nn4n

Recommended Posts

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!

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

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.