accessing network shares with opendir()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #1

    accessing network shares with opendir()

    I am trying to access files on a different drive but the same server to where the script is running.
    but I only get the error
    Code:
    failed to open dir: Invalid argument in C:\apache\xampp\htdocs\path\to\script
    I have tried the following combinations
    Code:
    if(opendir('S:/folder/'))
    	echo 'found';
    if(opendir('S:/folder))
    	echo 'found';
    if(opendir('S:\folder\\'))
    	echo 'found';
    if(opendir('S:\folder))
    	echo 'found';
    if(opendir('//10.1.1.11/S/folder/'))
    	echo 'found';
    if(opendir('//10.1.1.11/S/folder))
    	echo 'found';
    if(opendir('\\\10.1.1.11\S\folder\\'))
    	echo 'found';
    if(opendir('\\\10.1.1.11\S\folder))
    	echo 'found';
    The system is Windows 2003 server.
    Has anybody encountered this?
    Last edited by pbmods; Apr 18 '09, 09:44 PM. Reason: Fixed CODE tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Code Green.

    Try using Windows-style path delimiters, e.g.,
    [code=php]
    if(opendir('S:\ \folder\\'))
    [/code]

    For the sake of efficiency, you may want to use file_exists() instead of opnedir() to check to see if the directory exists.

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      Try using Windows-style path delimiters, e.g.,
      Code: ( php )
      if(opendir('S:\ \folder\\'))
      I'll give that a go.
      For the sake of efficiency, you may want to use file_exists() instead of opnedir() to check to see if the directory exists.
      I am using opendir() because I want to read all the file with readdir()
      Last edited by code green; Sep 24 '07, 08:23 AM. Reason: mistake

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        Sorry pbmods that didn't work either.
        I think it is an IIS issue

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, Code Green.

          Check out this comment.

          Comment

          • code green
            Recognized Expert Top Contributor
            • Mar 2007
            • 1726

            #6
            Thanks but that doesn't really help me.
            My php files and doc root are set up on the C drive.
            Thats fine I can see all the C drive folders.
            But I am trying to read files that are on the S drive.
            I can get around this by running the php script on the S drive using the command line or CLI but obviously not in the browser.
            That is OK but not ideal.

            Comment

            • DaveRandom
              New Member
              • Apr 2009
              • 3

              #7
              Hi all...

              Here is a full explaination of why this problem exists, and a work-around.

              The issue is basically one of NT Authentication, and can be resolved by manipulating the user accounts on the host system.

              Comment

              • code green
                Recognized Expert Top Contributor
                • Mar 2007
                • 1726

                #8
                Thanks DaveRandom
                I will be studying this page


                So far I can communicate between the Apache server
                and a simple disk storage system such as buffalo.
                But a network Windows server has always been a problem.

                Comment

                Working...