Using chdir with an absolute path

2.5k views Asked by At

I am trying to use chdir inside a function which writes & saves a file. If I try to write the file to a nearby folder e.g. 'bins' like so:

$location = 'bins';
chdir($location);

then it works fine and the files are written and placed into the bins folder. The problem I have is that I need to save the files onto a different drive like so:

$location = 'I:/directory/test/'
chdir($location);

but when I use an absolute path like above I get this error message:

Warning: chdir(): No such file or directory (errno 2) in index.php on line 586

Could someone explain what I'm doing wrong and how I can fix it please?

Thanks for any help

1

There are 1 answers

3
Your Common Sense On BEST ANSWER
  1. there is no point to use chdir() to save a file. just prepend file path with $location.
  2. chdir accepts absolute paths as well, so, there is indeed something wrong with given path. double-check it