Loading ...
Sorry, an error occurred while loading the content.

Want to browse the directory

Expand Messages
  • hiteshshah_it
    Dear friends, I want to browse the directory, if there is any subdirectory of it than that one also. It will give me a list like what we will get when we
    Message 1 of 5 , Aug 4, 2005
    • 0 Attachment
      Dear friends,
      I want to browse the directory, if there is any subdirectory
      of it than that one also. It will give me a list like what we will
      get when we browse the directory and get the list of all the files as
      well as all the details of it.
      I want to display the list of all the contains which falls in
      to the root directory.It will display n numbers of folder and its
      subfolder along with all the available files in to it.

      Help me in this scenario.


      Thanks,
      Hitz
    • ninad panday
      Hi Try following code snippet *****************
      Message 2 of 5 , Aug 4, 2005
      • 0 Attachment
        Hi
        Try following code snippet
        *****************
        <?
        $list = split("\n",`ls -l`);

        $pattern = "/[dwrx\-]{10}/";

        foreach($list as $file)
        {
        $file = preg_split("/
        /",$file,20,PREG_SPLIT_NO_EMPTY);

        echo join("|",$file) ."\n";
        //echo "$file[0]\n";
        }
        ?>
        **********
        --- hiteshshah_it <hiteshshah_it@...> wrote:

        > Dear friends,
        > I want to browse the directory, if there is
        > any subdirectory
        > of it than that one also. It will give me a list
        > like what we will
        > get when we browse the directory and get the list of
        > all the files as
        > well as all the details of it.
        > I want to display the list of all the
        > contains which falls in
        > to the root directory.It will display n numbers of
        > folder and its
        > subfolder along with all the available files in to
        > it.
        >
        > Help me in this scenario.
        >
        >
        > Thanks,
        > Hitz
        >
        >
        >


        __________________________________________________
        Do You Yahoo!?
        Tired of spam? Yahoo! Mail has the best spam protection around
        http://mail.yahoo.com
      • ninad panday
        Hi, You can refer http://www.php.net/manual/en/ref.dir.php Ninad ... __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo!
        Message 3 of 5 , Aug 4, 2005
        • 0 Attachment
          Hi,

          You can refer

          http://www.php.net/manual/en/ref.dir.php

          Ninad

          --- hiteshshah_it <hiteshshah_it@...> wrote:

          > Dear friends,
          > I want to browse the directory, if there is
          > any subdirectory
          > of it than that one also. It will give me a list
          > like what we will
          > get when we browse the directory and get the list of
          > all the files as
          > well as all the details of it.
          > I want to display the list of all the
          > contains which falls in
          > to the root directory.It will display n numbers of
          > folder and its
          > subfolder along with all the available files in to
          > it.
          >
          > Help me in this scenario.
          >
          >
          > Thanks,
          > Hitz
          >
          >
          >


          __________________________________________________
          Do You Yahoo!?
          Tired of spam? Yahoo! Mail has the best spam protection around
          http://mail.yahoo.com
        • anand tarey
          Message 4 of 5 , Aug 5, 2005
          • 0 Attachment
            <?
            getcontent($MyFolder);
            function getcontent($file)
            {
            if (file_exists($file))
            {

            if (is_dir($file))
            {
            $handle = opendir($file);
            while($filename = readdir($handle))
            {
            if ($filename != "." && $filename != "..")
            {
            echo $file."/".$filename;
            getcontent($file."/".$filename);
            }
            }
            closedir($handle);
            }
            else
            {
            echo($file);
            }
            }
            }
            ?>

            ninad panday <ninadpanday@...> wrote:

            Hi,

            You can refer

            http://www.php.net/manual/en/ref.dir.php

            Ninad

            --- hiteshshah_it <hiteshshah_it@...> wrote:

            > Dear friends,
            > I want to browse the directory, if there is
            > any subdirectory
            > of it than that one also. It will give me a list
            > like what we will
            > get when we browse the directory and get the list of
            > all the files as
            > well as all the details of it.
            > I want to display the list of all the
            > contains which falls in
            > to the root directory.It will display n numbers of
            > folder and its
            > subfolder along with all the available files in to
            > it.
            >
            > Help me in this scenario.
            >
            >
            > Thanks,
            > Hitz
            >
            >
            >


            __________________________________________________
            Do You Yahoo!?
            Tired of spam? Yahoo! Mail has the best spam protection around
            http://mail.yahoo.com


            Read Posting Guidelines at
            http://groups.yahoo.com/group/in-phpug/files/guidelines.html



            ---------------------------------
            YAHOO! GROUPS LINKS


            Visit your group "in-phpug" on the web.

            To unsubscribe from this group, send an email to:
            in-phpug-unsubscribe@yahoogroups.com

            Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


            ---------------------------------




            ---------------------------------
            Start your day with Yahoo! - make it your home page

            [Non-text portions of this message have been removed]
          • Milindkumar Patil
            Hi Hitesh, Try following code /////////////////////////////////////////////////////
            Message 5 of 5 , Aug 5, 2005
            • 0 Attachment
              Hi Hitesh,
              Try following code
              /////////////////////////////////////////////////////

              <?

              $dir_name = "/usr/local/temp"; //temp is directory that you want to browse
              $subdirectories = array();
              $files = array();
              if(is_dir($dir_name) && is_readable($dir_name))
              {
              $d = opendir($dir_name) or die("$php_errormsg"); //if in php.ini - track_error = On, then use global variable $php_errormsg
              while(false !== ($f = readdir($d) ))
              {
              if ("." == $f || ".." == $f) //skip .(current directory) and ..(parent directory)
              {
              continue;
              }

              if(is_dir("$dir_name/$f"))
              {
              array_push($subdirectories,"$dir_name/$f");
              }
              else
              {
              array_push($files,"$dir_name/$f");
              }
              }
              closedir($d) or die("$php_errormsg");

              foreach($subdirectories as $subdirectory)
              {
              $files = array_merge($files,$subdirectory); //if want to process subdirectory write same code or you
              //can create funtion using same code
              //and put it like this $file = array_merge($files,process($subdirectory))
              // where process() is function, then you can get subdirectory files listing too
              }
              }
              print_r($files);

              Here is an example: if /temp contains the files "a" and "b" as well as directiory "c",
              then $files gives an array with elements /temp/a,/temp/b and /temp/c(where c is subdirectory). To perform operation on each file,
              iterate through the array $files.

              foreach($files as $file)
              {
              print "$file was last accessed at".strftime('%c',fileatime($file))."\n";
              }

              ?>

              thxx
              Milind
              mkumarpatil@...


              hiteshshah_it <hiteshshah_it@...> wrote:
              Dear friends,
              I want to browse the directory, if there is any subdirectory
              of it than that one also. It will give me a list like what we will
              get when we browse the directory and get the list of all the files as
              well as all the details of it.
              I want to display the list of all the contains which falls in
              to the root directory.It will display n numbers of folder and its
              subfolder along with all the available files in to it.

              Help me in this scenario.


              Thanks,
              Hitz




              Read Posting Guidelines at
              http://groups.yahoo.com/group/in-phpug/files/guidelines.html



              SPONSORED LINKS
              Programming languages C programming language Computer programming languages Java programming language C programming language History of computer programming language

              ---------------------------------
              YAHOO! GROUPS LINKS


              Visit your group "in-phpug" on the web.

              To unsubscribe from this group, send an email to:
              in-phpug-unsubscribe@yahoogroups.com

              Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


              ---------------------------------




              ---------------------------------
              Yahoo! Mail
              Stay connected, organized, and protected. Take the tour

              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.