Jump to content

Newbie problme with chdir & getcwd


standsure

Recommended Posts

I am relatively new to php, so apologies for my lack of finesse in coding, etc.

 

I wanted to get information of files and folders on a specific drive. With the help of php sites like this I found various ways of getting what I need.

 

One such example:

<?php
// list the files in C default directory
echo "Default list: <br>";
print_r(glob('*.*'));
var_dump(getcwd());

// change to D drive
echo "<br> D Drive: <br>";
var_dump(chdir('D:'));
var_dump(getcwd());
print_r(glob('*'));

// change to E drive
echo "<br> E Drive: <br>";
var_dump(chdir('E:'));
var_dump(getcwd());
print_r(glob('*'));
?>

 

However, when I look at my E drive nothing is returned. No matter what I do I cant get php to show me what is in E. Any ideas on why C & D are ok but E is a problem (I have checked permissions and all drives are set the same).

 

Any help greatly appreciated…

 

php1.jpg

php2.jpg

php3.jpg

 

Link to comment
Share on other sites

The output of code example:

 

Default list:

Array ( [0] => AccessDenied.aspx [1] => AccessDenied.aspx.cs [2] => Admin.aspx [3] => Admin.aspx.cs [4] => AllPages.aspx [5] => AllPages.aspx.cs [6] => Category.aspx [7] => Category.aspx.cs [8] => Default.aspx [9] => Default.aspx.cs [10] => Diff.aspx [11] => Diff.aspx.cs [12] => Directory.php [13] => Edit.aspx [14] => Edit.aspx.cs [15] => Error.aspx [16] => Error.aspx.cs [17] => FileList.ascx [18] => FileList.ascx.cs [19] => GPL.txt [20] => GetFile.aspx [21] => GetFile.aspx.cs [22] => GetThumb.aspx [23] => GetThumb.aspx.cs [24] => Global.asax [25] => History.aspx [26] => History.aspx.cs [27] => Import.aspx [28] => Import.aspx.cs [29] => InputPage.php [30] => InputPage_old.php [31] => JsFileTree.ascx [32] => JsFileTree.ascx.cs [33] => JsImageBrowser.ascx [34] => JsImageBrowser.ascx.cs [35] => Language.aspx [36] => Language.aspx.cs [37] => LogList.ascx [38] => LogList.ascx.cs [39] => Login.aspx [40] => Login.aspx.cs [41] => MasterPage.master [42] => MasterPage.master.cs [43] => Message.aspx [44] => Message.aspx.cs [45] => MySqlWeb.php [46] => MySqlWebResults.php [47] => MySqlWebResults2.php [48] => NavPath.aspx [49] => NavPath.aspx.cs [50] => Operation.aspx [51] => Operation.aspx.cs [52] => PageNotFound.aspx [53] => PageNotFound.aspx.cs [54] => Post.aspx [55] => Post.aspx.cs [56] => Preview.aspx [57] => Preview.aspx.cs [58] => Print.aspx [59] => Print.aspx.cs [60] => Profile.aspx [61] => Profile.aspx.cs [62] => RSS.aspx [63] => RSS.aspx.cs [64] => RandPage.aspx [65] => RandPage.aspx.cs [66] => Register.aspx [67] => Register.aspx.cs [68] => Search.aspx [69] => Search.aspx.cs [70] => SessionRefresh.aspx [71] => SessionRefresh.aspx.cs [72] => Thumbs.db [73] => Upload.aspx [74] => Upload.aspx.cs [75] => WebSols.php [76] => WebSolsStatus.php [77] => WebSols_Count_Status.php [78] => Zip.aspx [79] => Zip.aspx.cs [80] => index.htm [81] => nagios.php [82] => phpMyAdmin-2.11.4-all-languages-utf-8-only [83] => results.php [84] => results_old.php [85] => robots.txt [86] => test.php [87] => test1.php [88] => web.config ) string(27) "C:\Inetpub\wwwroot\PerfWiki"

 

D Drive:

bool(true) string(3) "D:\" Array ( [0] => System Volume Information [1] => Test )

 

E Drive:

bool(true) string(3) "E:\" Array ()

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.