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

Re: [bang-phpug] error in readdir function

Expand Messages
  • 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 1 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.