php-windows Digest 29 Sep 2003 03:23:02 -0000 Issue 1931

Topics (messages 21580 through 21582):

File Ext
        21580 by: Dean Hayes
        21581 by: H Marc Bower

Problem: URL Encoded Parameters
        21582 by: The Hub

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hey,


I need to be able to find out what the file ext is on all files within the dir i am reading. I am searched the php manual and i can not find anything that does this does anyone know of a way i can and print it out.

Thanks


Dean "The Insane Guy" Hayes Mystical Web Designs http://www.mystical-sector.com

<-- I design and i redesign but still i never designed true beauty like you -->

_________________________________________________________________
E-mail just got a whole lot better. New ninemsn Premium. Click here http://ninemsn.com.au/premium/landing.asp

--- End Message ---
--- Begin Message ---
This will work, with several caveats since the purpose is not known.......

<?php
 $dir = dir("c:/");
 while($filename=$dir->read())
 {
  if (!is_dir($filename))
  {
   clearstatcache();
   $extension = substr($filename,-4);
   $realext = strstr($extension, ".");
   if ($realext <> "")
   {
    echo $realext."<br>\n";
   }
  }
 }
 $dir->close();
?>

Output for me looked like this:
.BAT
.ini
.SYS
.sys
.SYS
.SYS
.cnf
.COM

One of the exceptions is that the is_dir function doesn't really seem to
work on windows/IIS.  Since this is the only test environment I have, I can
only assume that it does work ok with a linux-based webserver or it wouldn't
be in there. In fact, if I put in is_file() instead of !is_dir, it returns
nothing at all.  Anyway, that takes a list of all files and directory names
in the given directory (c:/ - yes it has to be a / not a \ - in my example),
checks to see if it's a directory or a file (theoretically...), then grabs
the last 4 characters that start with a ".", tosses them onto the screen.
Replace the last echo with whatever manipulation you're going for.  The
things this will include that it shouldn't:  directories with a 3-character
extension.  Things it won't include that you might need:  files with a
4-character-or-more or a 2-character-or-less extension.  It only grabs
3-character extensions.  From here, though, I think you can modify it to do
whatever it is you need done.

(V)

----- Original Message ----- 
From: "Dean Hayes" <[EMAIL PROTECTED]>
> Hey,
>
> I need to be able to find out what the file ext is on all files within the
> dir i am reading. I am searched the php manual and i can not find anything
> that does this does anyone know of a way i can and print it out.

--- End Message ---
--- Begin Message ---
I've found it very useful to put PHP parameters after the ? in URLs, and
then access it with it's name in the next page.
e.g.
file.php?param=true&param2=hello

Then in file.php:
echo $param . "\n";
echo $param2 . "\n";

Here's my problem:
this seems to only work on Linux systems, because whenever I try it on a
Windows machine I get nothing. It's as if the URL just said file.php

How do I fix this?


 - Patrick

--- End Message ---

Reply via email to