Re: [phplib] Extension of Files From: NickM (nick <email protected>)
Date: 07/07/00

If it's just for gif and jpg then you can use GetImageSize(), it also tells you what type of image it is.

Nick

  ----- Original Message -----
  From: Jose Luis Rodríguez Sevilla
  To: phplib <email protected>
  Sent: Friday, July 07, 2000 2:51 PM
  Subject: [phplib] Extension of Files

  I want to know if a file ($f) is an image file; i try to extract the extension (.gif or .jpg) of this file but i don't know how i can do it.

  If you know how, tell me a part of code of this or an example.

   if (isset($FILE)){
    $f = $FILE;
    if (filesize($f) < $max_file_size){

     $complet_file = explode(".", $FILE);
     $pos = count($complet_file);
     $pos = $pos - 1;
     $extension = $complet_file[$pos];
     
     $ext = strtolower($extension);

     if (($ext == "gif") || ($ext == "jpg")){
  ..........

  }

  Thank You.