Re: Spaces in filename or path

From: Date: Sat, 30 Apr 2011 21:33:50 +0000
Subject: Re: Spaces in filename or path
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-312602@lists.php.net to get a copy of this message
On 30 April 2011 22:07, Tim Streater <tim@clothears.org.uk> wrote: > Does it matter to PHP filesystem functions if a path/to/file/name contains spaces? IOW, is this > handled OK by design or should I replaces such spaces by backslash-space or would doing that present > problems? > > Thanks  --  tim On Windows, PHP will happily access files and directories with spaces... <?php file_put_contents('My name is Richard.txt', 'Hello Richard');" ?> If you intend to pass the filename to a command line tool, then the filename must be wrapped with double quotes ... <?php exec('tool.exe "My name is Richard.txt"'); ?> If you intend to pass the filename to a command line tool and the tool has spaces in the name too, then you need to wrap both with quotes ... <?php exec('"C:\Program Files\tool.exe" "My name is Richard.txt"'); ?> If you are using a version of PHP before V5.3.0, please read http://uk.php.net/manual/en/function.exec.php#101579. Your code would need to be ... <?php exec('""C:\Program Files\tool.exe" "My name is Richard.txt""'); ?> I've added some _ to that so you can easily see the single and double quotes ... (they aren't part of the real code, just there to show you the quotes) ... <?php exec(_'_"_"_C:\Program Files\tool.exe_"_ _"_My name is Richard.txt_"_"_'_); ?> -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

« previous php.general (#312602) next »