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

error in readdir function

Expand Messages
  • pritesh loke
    Hello To All I need one help i am trying to read files from the dir and using php readdir.So i write one smoll code related to this but they give me one error.
    Message 1 of 4 , Oct 15, 2006
    • 0 Attachment
      Hello To All
      I need one help i am trying to read files from the dir and using php readdir.So i write one smoll code related to this but they give me one error.

      Code :

      $fp = "img";
      while(false !==($file=readdir($fp)))
      {
      if($file!="."&& $file="..")
      {
      $files[] = $file;
      }
      }
      $total = count($files);
      for($i=0;$i<$total;$i++)
      {
      $temp_files[] = $files[$i];
      }
      //$current_file = $temp_file[]
      $smarty->assign("filesname",$temp_files);
      $smarty->display("ImageUpload.tpl");
      i am reading all files from the img dir and stored in the $temp_files array.

      error :
      Warning: readdir(): supplied argument is not a valid Directory resource in D:\Program Files\xampp\htdocs\pml\smartydemo\ImageProcess.php on line 16
      line 16 = while(false !==($file=readdir($fp)))

      pls give me idea about what is the error.img folder is there.but stil they give me error.
      Pls give me reply

      Thank you.





      ---------------------------------
      Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

      [Non-text portions of this message have been removed]
    • jatinder kaur
      pritesh, u just try to give complete path in $fp and let me know. jatinder ... [Non-text portions of this message have been removed]
      Message 2 of 4 , Oct 17, 2006
      • 0 Attachment
        pritesh,
        u just try to give complete path in $fp and let me know.
        jatinder


        On 10/16/06, pritesh loke <priteshloke@...> wrote:
        >
        > Hello To All
        > I need one help i am trying to read files from the dir and using php
        > readdir.So i write one smoll code related to this but they give me one
        > error.
        >
        > Code :
        >
        > $fp = "img";
        > while(false !==($file=readdir($fp)))
        > {
        > if($file!="."&& $file="..")
        > {
        > $files[] = $file;
        > }
        > }
        > $total = count($files);
        > for($i=0;$i<$total;$i++)
        > {
        > $temp_files[] = $files[$i];
        > }
        > //$current_file = $temp_file[]
        > $smarty->assign("filesname",$temp_files);
        > $smarty->display("ImageUpload.tpl");
        > i am reading all files from the img dir and stored in the $temp_files
        > array.
        >
        > error :
        > Warning: readdir(): supplied argument is not a valid Directory resource in
        > D:\Program Files\xampp\htdocs\pml\smartydemo\ImageProcess.php on line 16
        > line 16 = while(false !==($file=readdir($fp)))
        >
        > pls give me idea about what is the error.img folder is there.but stil they
        > give me error.
        > Pls give me reply
        >
        > Thank you.
        >
        >
        > ---------------------------------
        > Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
        > countries) for 2¢/min or less.
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      • pritesh loke
        Hello Sri, I am using smarty so i have structure like templates and img .where in img i stored the all the images which i am listing ok.in the templates folder
        Message 3 of 4 , Oct 17, 2006
        • 0 Attachment
          Hello Sri,
          I am using smarty so i have structure like templates and img .where in img i stored the all the images which i am listing ok.in the templates folder i stored my all the tpl file.but my img folder path is correct.but still they give me error.can you know any other type of the creating this type of listing.pls give me repl.

          Thank you.

          jatinder kaur <jatinderkaur100@...> wrote: pritesh,
          u just try to give complete path in $fp and let me know.
          jatinder

          On 10/16/06, pritesh loke <priteshloke@...> wrote:
          >
          > Hello To All
          > I need one help i am trying to read files from the dir and using php
          > readdir.So i write one smoll code related to this but they give me one
          > error.
          >
          > Code :
          >
          > $fp = "img";
          > while(false !==($file=readdir($fp)))
          > {
          > if($file!="."&& $file="..")
          > {
          > $files[] = $file;
          > }
          > }
          > $total = count($files);
          > for($i=0;$i<$total;$i++)
          > {
          > $temp_files[] = $files[$i];
          > }
          > //$current_file = $temp_file[]
          > $smarty->assign("filesname",$temp_files);
          > $smarty->display("ImageUpload.tpl");
          > i am reading all files from the img dir and stored in the $temp_files
          > array.
          >
          > error :
          > Warning: readdir(): supplied argument is not a valid Directory resource in
          > D:\Program Files\xampp\htdocs\pml\smartydemo\ImageProcess.php on line 16
          > line 16 = while(false !==($file=readdir($fp)))
          >
          > pls give me idea about what is the error.img folder is there.but stil they
          > give me error.
          > Pls give me reply
          >
          > Thank you.
          >
          >
          > ---------------------------------
          > Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
          > countries) for 2¢/min or less.
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >

          [Non-text portions of this message have been removed]








          ---------------------------------
          Do you Yahoo!?
          Everyone is raving about the all-new Yahoo! Mail.

          [Non-text portions of this message have been removed]
        • Andy Nagai
          hi you first use opendir() to get the file pointer to the dir then you loop through the dir with readdir(). your getting an error cause the param in readdir is
          Message 4 of 4 , Oct 17, 2006
          • 0 Attachment
            hi

            you first use opendir() to get the file pointer to the dir then you loop through the dir with readdir(). your getting an error cause the param in readdir is not a file pointer. if server is on windows, use complete dir path including drive letter. Please use PHP documentation. just search for the readdir command and you get an example code. They have an searchable online help file or downloadable windows help file. Life will be alot easier. Life is not supposed to be this hard with php.

            try this:

            if ($fp = opendir('/path/to/files')) //do only if path exists
            {

            while (false != = ($file = readdir($fp)))
            {
            echo "$file\n";
            }
            }




            ----- Original Message ----
            From: jatinder kaur <jatinderkaur100@...>
            To: bang-phpug@yahoogroups.com
            Sent: Tuesday, October 17, 2006 10:55:24 AM
            Subject: Re: [bang-phpug] error in readdir function

            pritesh,
            u just try to give complete path in $fp and let me know.
            jatinder

            On 10/16/06, pritesh loke <priteshloke@ yahoo.com> wrote:
            >
            > Hello To All
            > I need one help i am trying to read files from the dir and using php
            > readdir.So i write one smoll code related to this but they give me one
            > error.
            >
            > Code :
            >
            > $fp = "img";
            > while(false !==($file=readdir( $fp)))
            > {
            > if($file!=". "&& $file="..")
            > {
            > $files[] = $file;
            > }
            > }
            > $total = count($files) ;
            > for($i=0;$i< $total;$i+ +)
            > {
            > $temp_files[ ] = $files[$i];
            > }
            > //$current_file = $temp_file[]
            > $smarty->assign( "filesname" ,$temp_files) ;
            > $smarty->display( "ImageUpload. tpl");
            > i am reading all files from the img dir and stored in the $temp_files
            > array.
            >
            > error :
            > Warning: readdir(): supplied argument is not a valid Directory resource in
            > D:\Program Files\xampp\ htdocs\pml\ smartydemo\ ImageProcess. php on line 16
            > line 16 = while(false !==($file=readdir( $fp)))
            >
            > pls give me idea about what is the error.img folder is there.but stil they
            > give me error.
            > Pls give me reply
            >
            > Thank you.
            >
            >
            > ------------ --------- --------- ---
            > Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
            > countries) for 2¢/min or less.
            >
            > [Non-text portions of this message have been removed]
            >
            >
            >

            [Non-text portions of this message have been removed]








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