Page 1 of 1

Dynamic Filesystem: problem with --> / in file paths

Posted: Thu Jul 12, 2007 11:23 pm
by X_Citer
Hi, I am creating a dynamic filesystem for my very small web hosting company. It uses a username cookie to access a specific folder and for the life of me i cannot make the \ at the end of the file paths work correctly without sending it on a none existant file path. PLEASE HELP!!

$folder=$_COOKIE['username'];
$path="C:\Program Files\Cerberus\FTP Clients\.".$folder;
$dir_handle= opendir($path) or die("Unable to open FTP client");

Posted: Thu Jul 12, 2007 11:47 pm
by feyd
The folders are have a leading dot?

Posted: Thu Jul 12, 2007 11:50 pm
by X_Citer
No but you cant put a \" it throws an error every time... that's the problem... it needs that slash at the end.

Posted: Thu Jul 12, 2007 11:58 pm
by Benjamin
A \ is also an escape character, so it needs to be escaped...

Code: Select all

$folder=$_COOKIE['username'];
$path="C:\\Program Files\\Cerberus\\FTP Clients\\".$folder;
$dir_handle= opendir($path) or die("Unable to open FTP client");
I believe that should work for you. I haven't ran across this in ages though, as I don't run scripts in windows.

Posted: Fri Jul 13, 2007 12:01 am
by X_Citer
Yep that solved it fine.. thanks for all the help :)