www.webdeveloper.com
Results 1 to 3 of 3

Thread: Trouble opening file located in different directory

  1. #1
    Join Date
    Apr 2010
    Location
    Brooklyn NY
    Posts
    104

    Trouble opening file located in different directory

    I keep getting file not found while trying to traverse the directories on my server.

    For example I try to go up two folders to my root using the command chdir('../../') and then I've tried these two variations

    PHP Code:
    chdir('../../scripts/misc/');
    $file_name "Tutorial.json";
    $file_handler fopen($file_name,"r") or exit($_GET['callback'] . '("' getcwd() .'");');

    // or

    $file_name 'scripts/misc/Tutorial.json'
    for getcwd() I keep getting /home/users/web/b2440/moo._my_username_

  2. #2
    Join Date
    Apr 2011
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    33
    If this is a shared server, it *looks* as if (from the directory structure) that you can't go above moo._my_username_ (which makes sense).

    Have you tried calling the desired script/resource with an absolute path?

  3. #3
    Join Date
    Apr 2010
    Location
    Brooklyn NY
    Posts
    104
    I got it resolved, but yes, I tried an absolute path, and still nothing.

    This is what worked for me. It be have extra unneccessary code, but I haven't gotten around to testing what's not needed

    PHP Code:
    chdir('../../');
        
    $myDirectory opendir("scripts/misc/");
        
        
    // get each entry
        
    while($entryName readdir($myDirectory)) {
            
    $dirArray[] = $entryName;// used this to check what files were there
        
    }
        
        
    $res json_decode($_GET['data'],true);
        
        
    $file_name "scripts/misc/Tutorial.json"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles