Kasper
Kasper

Reputation: 1292

PHP replace double backslashes "\\" to a single backslash "\"

Okay so im working on this php image upload system but for some reason internet explorer turns my basepath into the same path, but with double backslashes instead of one; ie:

C:\\Documents and Settings\\kasper\\Bureaublad\\24.jpg

This needs to become C:\Documents and Settings\kasper\Bureaublad\24.jpg.

Upvotes: 5

Views: 17538

Answers (3)

The.Anti.9
The.Anti.9

Reputation: 44648

Use the stripslashes function.

That should make them all single slashes.

Upvotes: 1

moltenform
moltenform

Reputation: 801

Note that you may be running into PHP's Magic Quotes "feature" where incoming backslashes are turned to \\.

See https://www.php.net/magic_quotes

Upvotes: 2

devinmoore
devinmoore

Reputation: 2756

Have you considered the stripslashes() function?

http://www.php.net/stripslashes

Upvotes: 1

Related Questions