Re: Escape slashes?

From: Date: Tue, 13 Mar 2001 09:53:46 +0000
Subject: Re: Escape slashes?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-43640@lists.php.net to get a copy of this message
On Monday 12 March 2001 20:27, you wrote: > Hi! > > I am trying to do some fileuploading.. but I am running into a problem > with escaping spaces. > > Basically, I have this directory that includes spaces and I need to be > able to change the spaces to "\ " so for example.. > > my directory is: Fun Documents > I need to change it to: Fun\ Documents > > That way when I copy.. I wont get errors! Plus, there is always the > potential that the filename might have a space in it. Why would you get an error when copying? copy(), fopen() and all the rest should work fine with filenames-with-spaces. > So how do I escape these spaces? > > I have tried this.. and it doesnt work: > $copyto = strtr($copyto, " ", "\ "); strtr () is for "TRanslating" strings between character sets, i.e. it replaces single characters with single other characters strtr ($SomeString, "abc", "qwe"); will replace all "a" with "q", all "b" with "w" and all "c" with "e" > I am sorta clueless.. any ideas? Well, as I said above you shouldn't need this, and in fact this could become a quite unstable solution. You escape spaces - but what about filenames containing tabs, newlines etc? copy () takes care of that automatically. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) I sat laughing snidely into my notebook until they showed me a PC running Linux. And oh! It was as though the heavens opened and God handed down a client-side OS so beautiful, so graceful, and so elegant that a million Microsoft developers couldn't have invented it even if they had a hundred years and a thousand crates of Jolt cola. - LAN Times

« previous php.general (#43640) next »