how to create directory+subdirectory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tomek

    #1

    how to create directory+subdirectory

    hi
    i'm desperate... i'm trying this for 2 days now... so if anyone can help -
    please.

    i have upload form in which users can choose TYPE of file they are uploading
    (graphic/text/music) - and STATUS of that file (draft/finished). So, my
    upload script is getting:
    - $_FILE field,
    - TYPE of file (it is string representing "DIRECTORY" )
    - STATUS of file (it is string representing "SUBDIRECTO RY")

    i cannot find working function or script to upload file to
    "DIRECTORY/SUBDIRECTORY/" if that 2 dirs doesn' exist.

    how can i create 2 dirs ? i tried recursively...
    =============== =============== =============== ====

    function mkdirs($dir, $mode = 0777, $recursive = true) {
    if( is_null($dir) || $dir === "" ){
    return FALSE;
    }
    if( is_dir($dir) || $dir === "/" ){
    return TRUE;
    }
    if( mkdirs(dirname( $dir), $mode, $recursive) ){
    return mkdir($dir,0777 ); // the default chmod
    }
    return FALSE;
    }
    =============== =============== =============== =====

    but it only creates first one, but not other (subdirectory) - like created
    dir doesn't have permissions ??

    anyone?



  • Steve

    #2
    Re: how to create directory+subdi rectory

    On Mon, 23 Jan 2006 09:24:10 +0100, tomek wrote:
    [color=blue]
    > hi
    > i'm desperate... i'm trying this for 2 days now... so if anyone can help -
    > please.
    >
    > i have upload form in which users can choose TYPE of file they are uploading
    > (graphic/text/music) - and STATUS of that file (draft/finished). So, my
    > upload script is getting:
    > - $_FILE field,
    > - TYPE of file (it is string representing "DIRECTORY" )
    > - STATUS of file (it is string representing "SUBDIRECTO RY")
    >
    > i cannot find working function or script to upload file to
    > "DIRECTORY/SUBDIRECTORY/" if that 2 dirs doesn' exist.
    >
    > how can i create 2 dirs ? i tried recursively...
    > =============== =============== =============== ====
    >
    > function mkdirs($dir, $mode = 0777, $recursive = true) {
    > if( is_null($dir) || $dir === "" ){
    > return FALSE;
    > }
    > if( is_dir($dir) || $dir === "/" ){
    > return TRUE;
    > }
    > if( mkdirs(dirname( $dir), $mode, $recursive) ){
    > return mkdir($dir,0777 ); // the default chmod
    > }
    > return FALSE;
    > }
    > =============== =============== =============== =====
    >
    > but it only creates first one, but not other (subdirectory) - like created
    > dir doesn't have permissions ??
    >
    > anyone?[/color]

    have you got safe mode enabled? won't work then.

    Comment

    • ToMeK

      #3
      Re: how to create directory+subdi rectory

      > >[color=blue][color=green]
      > > how can i create 2 dirs ? i tried recursively...
      > > =============== =============== =============== ====
      > > but it only creates first one, but not other (subdirectory) - like[/color][/color]
      created[color=blue][color=green]
      > > dir doesn't have permissions ??
      > >
      > > anyone?[/color]
      >
      > have you got safe mode enabled? won't work then.[/color]

      how can i know is that safemode enabled and where can i enabe it?


      Comment

      • ToMeK

        #4
        Re: how to create directory+subdi rectory


        "ToMeK" <t_mih@hotmail. com> wrote in message
        news:dr29j9$dt2 $1@ss405.t-com.hr...[color=blue][color=green][color=darkred]
        > > >
        > > > how can i create 2 dirs ? i tried recursively...
        > > > =============== =============== =============== ====
        > > > but it only creates first one, but not other (subdirectory) - like[/color][/color]
        > created[color=green][color=darkred]
        > > > dir doesn't have permissions ??
        > > >
        > > > anyone?[/color]
        > >
        > > have you got safe mode enabled? won't work then.[/color]
        >
        > how can i know is that safemode enabled and where can i enabe it?
        >
        >[/color]

        i just contacted my provider and he says that they cannot change "safe_mode"
        tag.
        he mention something about "create directories with my UID" ? can anyone
        tell me more details on that? (UID)

        thanks.

        is there another way? maybe ftp?


        Comment

        • Jim Michaels

          #5
          Re: how to create directory+subdi rectory


          "ToMeK" <t_mih@hotmail. com> wrote in message
          news:dr2acv$fqf $1@ss405.t-com.hr...[color=blue]
          >
          > "ToMeK" <t_mih@hotmail. com> wrote in message
          > news:dr29j9$dt2 $1@ss405.t-com.hr...[color=green][color=darkred]
          >> > >
          >> > > how can i create 2 dirs ? i tried recursively...
          >> > > =============== =============== =============== ====
          >> > > but it only creates first one, but not other (subdirectory) - like[/color]
          >> created[color=darkred]
          >> > > dir doesn't have permissions ??
          >> > >
          >> > > anyone?
          >> >
          >> > have you got safe mode enabled? won't work then.[/color]
          >>
          >> how can i know is that safemode enabled and where can i enabe it?
          >>
          >>[/color]
          >
          > i just contacted my provider and he says that they cannot change
          > "safe_mode"
          > tag.
          > he mention something about "create directories with my UID" ? can anyone
          > tell me more details on that? (UID)[/color]

          user id? it sould like he's referring to an ftp client thing
          look. you have a function that creates one directory successfully.
          sometimes you can create a whole path at once. it is possible you have to
          create them nested one by one. so maybe you have to explode() the dir
          string and walk through them one by one & chdir+mkdir. you could do it
          recursively, or iteratively.
          it's just another method.
          you might also consider that you might need to chdir somewhere first before
          you start your first mkdir, or at least prepend an absolute path like (what
          was it?) $_SERVER[DOCUMENT_ROOT]. Otherwise, who knows where your created
          directory will end up. and because of that, it might fail if it's in a
          restricted area.
          [color=blue]
          >
          > thanks.
          >
          > is there another way? maybe ftp?
          >
          >[/color]


          Comment

          Working...