www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Make a directory is an existing directory?

  1. #1
    Join Date
    Nov 2006
    Posts
    84

    resolved [RESOLVED] Make a directory is an existing directory?

    I am unable to make a new directory in an existing directory that is one level up from where my script is located. Here's my folder structure:

    Code:
    html
         > api
              > script.php
         > clients
              > [WHERE I WANT TO CREATE A FOLDER]
    I've tried using chdir("../clients") prior to running mkdir("./newfolder") but I get some strange error. Is that even how I should do this?

    Racking my brain on this one...

    Thanks everyone.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,923
    It would help to tell us what the "strange" error is.

    Without knowing, all I can do is guess that it's a permissions issue, which is often the case when you set up your site using your host login account, but then your PHP scripts are executed by the Apache account. Thus you may have to set read/write/execute for all on the directory where you want your script to create the directory -- which may have security ramifications, so choose wisely where you want this to happen in your directory tree.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Nov 2006
    Posts
    84
    I'm using a MediaTemple Gridserver (shared). The error I receive when i try to use the absolute path is:

    Warning: mkdir(): open_basedir restriction in effect. File() is not within the allowed path(s): [GS-BIN PATH HERE] in [SCRIPT PATH HERE]script.php on line 21
    Here's the code I'm using:

    PHP Code:
    chdir("../clients");
    mkdir("newfolder",0777); 
    When I use ./newfolder instead of newfolder I get an already exists error. Not sure what the correct syntax is. All folders have 777 permissions.

  4. #4
    Join Date
    Nov 2006
    Posts
    84
    Typo was causing the error, first sign I need to take a break

    Thanks.

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