Jump to content

opendir('\\\networkdrive\\folder')


tabasca

Recommended Posts

hi everybody here,

I need some help from an expert.

So, I created a website for my company. I want to list a network directory using php script.

I use opendir() function but no way. I received a Warning message telling that the result was to large !!!

 

I tryed several combination of "//" and "\\" and the pb still . :shrug:

 

please help if any  :'(

 

thks

Link to comment
Share on other sites

Hi,

 

this is my code :

 

<?php

 

function open_dir ($dir_name)

{

    if ($handle = opendir ($dir_name))

    {

    while (($file = readdir($handle)) != false)

        {

            if ($file != '.' && $file != '..')

         

            if (filetype($dir_name.'/'.$file)== 'dir')

            {

                open_dir ($dir_name.'/'.$file);

            }

            else

            {

                echo "-----  ".$dir_name.'/'.$file."<br>";

            }

        }

    closedir($handle);

    }

 

}

 

 

error_reporting(E_ALL);

ini_set('display_errors', '1');

 

//$rep = "c:";                                                          //  work fine with this declaration

//$rep = "////MyNetworkDrive/Diretory01/";          //  dosn't work  (see message error)

$rep="\\\localhost\\web";                                      // dosn't work  (see message error)

 

open_dir($rep);

 

?>

 

 

Error message :

 

Warning: opendir(//localhost/web) [function.opendir]: failed to open dir: Result too large in D:\MySites\tpoe\web\dir.php on line 5

 

Link to comment
Share on other sites

The slash escaping doesn't look right on the ones that aren't working. If that doesn't help, I don't know what else to suggest.

 

//$rep = "c:";                                                          //  work fine with this declaration
//$rep = "////MyNetworkDrive/Diretory01/";            //  try //MyNetworkDrive/Directory/01/
$rep="\\\localhost\\web";                                      // try \\\\localhost\\web\\

Link to comment
Share on other sites

hi guys,

 

I've tryed what you told me.

system("net use O: \\\MyNetworkDrive/Diretory  mypass/user:myid /persistent:no>nul 2>&1, $rep");

open_dir($rep);

 

And actually, I tart receiving this message :

 

Warning: system() [function.system]: Unable to fork [net use O: \\MyNetworkDrive/Diretory  mypass/user:myid /persistent:no>nul 2>&1] in D:\MySites\tpoe.ort\web\dir.php on line 43

 

Warning: opendir(-1) [function.opendir]: failed to open dir: No error in D:\MySites\tpoe.ort\web\dir.php on line 5

 

 

I want to know the meaning of this warning messages and if there is any solution /

 

Thanks

Link to comment
Share on other sites

This should be of some use to you.

PS.  I found it with Google using the search term "Unable to fork"; and it was the first one on the list

 

http://www.somacon.com/p255.php

 

A quote from the page

In Windows, when trying to execute a system call from a PHP script, you receive a warning like "Warning: system() [function.system]: Unable to fork". A related warning message is "Warning: shell_exec() [function.shell-exec]: Unable to execute"

 

Cause

The most likely cause is insufficient permissions to execute system calls in the web server environment.

 

Fix

You need to give the Internet Guest Account (a.k.a. IUSR_MachineName or simply IUSR) read and execute permission to the command shell program, cmd.exe. Typically, permission to this file is explicitly denied as a security measure.

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.