Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

opendir() PHP

  • 14-02-2003 8:58am
    #1
    Closed Accounts Posts: 59 ✭✭


    Could someone please tell me how to use the opendir() php function...... or is it even the right function to use if i want to
    fread()
    from a text file that is saved on a mapped network drive
    Thanks...


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    As it says in the manual - and as the name implies - opendir() is for working with directories. Have a look at the filesystem functions, specifically fopen() and file(). The documentation for fread() provides a full example by the way, did you try that before posting here?

    adam


  • Closed Accounts Posts: 59 ✭✭Fi_C**


    Ya I did read the manual on php.net...
    However my code just won't work!!
    I don't understand that whole lot about networks and servers and stuff. THis is wot I've been doing and the if statement keeps failing... when I try to access my s drive -- it's fine when i use it for local drives!!


    if ($dir = @opendir("s:\\"))
    {
    while (($file = readdir($dir)) != false)
    {
    echo "$file\n";
    }
    closedir($dir);
    }
    else echo ("<br>Connecting to network drive failing");

    $file = fopen($filename, "r");
    #$file = fopen("test.txt", "r");
    if(!$file) echo("Cannot open File");
    $text = fread($file, $maxfilesize);
    fclose($file);:mad:


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    Yes it works great locally, but you have to tell us where the directory is, in relation to the root of your site

    eg

    the directory is a directory in a directory, etc

    and also where the page is being placed that is using the opendir function


  • Closed Accounts Posts: 59 ✭✭Fi_C**


    This is the exact location of the file:
    $filename = "$loc\03 minutes of meetings\$mT\$name";

    $loc=" s:\\systems\projects\project_name\"
    $mT="type-of_meeting\"
    $name = document name.

    This is for an intranet site not 100% sure where it will eventually be placed --- at the moment it is on apache server

    whereas the files are on NT server...
    Does it have something to do with permissions on apache??
    :confused:


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    I remember that using opendir, only works on the server where the script is located, but if you are trying to access other files on "another computer", they have to be linked via a [url]http://[/url] call or ip address

    eg
    if ($dir = @opendir(&quot;s:\\"))
    {
    while (($file = readdir($dir)) != false)
    {
    echo "$file\n";
    }
    closedir($dir);
    }
    else echo ("<br>Connecting to network drive failing");

    $file = fopen($filename, "r");
    #$file = fopen("test.txt", "r");
    if(!$file) echo("Cannot open File");
    $text = fread($file, $maxfilesize);
    fclose($file);

    will work fine on a local test

    but a live test on a server, it will not work as it relates to securities and permissions. best bet is to have all relevant files located on the one machine


  • Advertisement
Advertisement