Results 1 to 4 of 4

Thread: Directory in directory

  1. #1
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default Directory in directory

    PHP Code:
    mkdir($path $gal_name);
    mkdir($path $gal_name "/thumb"); 
    Should this work or am I missing something? I want to create 2 directories at a time. Without the second line it was working, but when I put the second line in it created a directory that I couldnt access with my ftp or rmdir.

  2. The Following User Says Thank You to bluewalrus For This Useful Post:

    sachin1987 (01-05-2010)

  3. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Looks fine to me, assuming $path and $gal_name make sense-- is there a slash being added between those, or are they becoming one string-- $pathgal_name, not $path/$gal_name?

    It may be an issue with folder permissions. You can use the second parameter to create it with 0777 (all access).
    Then the third parameter can be used to make it recursive, and save you a bit of work.
    http://php.net/manual/en/function.mkdir.php
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    I think the variables are correct...

    $path = "./images/$user/";
    $gal_name = "users text input";
    $user = "text string depending on user";

    What are the default settings if 0777 isn't set? Does that only grant the php user access?

  5. #4
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Just try
    PHP Code:
    mkdir($path $gal_name "/thumb",0777true); 
    But for security reason use this
    PHP Code:
     $gal_name preg_replace("/[\/\.\s]/","",$gal_name); 
    this will remove slashes, dots and whitespaces

Bookmarks

Posting Permissions

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