hi i have a following form in html:

<form action="upload_file.php" method="post" enctype="multipart/form-data"> File Name: <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form>

and here is my upload_file.php

if (($_FILES["file"]["type"] != "file/XML"))

  echo "Invalid file type";
    echo 'file is uploaded';

it give Invalid file type i want to upload a file of .xml
help me in this regard

Go ahead and try this :

     * @static
     * @param $filename
     * @param bool $comma
     * @return bool|string
    public static function getFileExtension($filename, $comma = false) {
      if (strrpos($filename, '.')){
        $extension = substr($filename, strrpos($filename, '.'));

        return $comma ? $extension : substr($extension, 1);
      } else
         return false;


Also, make sure you use this only on upload

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.