title: exif_imagetype() [function.exif-imagetype]: Filename cannot be empty
body: <p>I have a website where i have given my users an option to upload their picture and i have set a condition like if they didnt select any file for uploading and if they click the upload button without choosing a picture they get an alert box, but apart from that my website is showing the error that i am pasting below.</p>
  
  <blockquote>
    <p>Warning: exif_imagetype() [function.exif-imagetype]: Filename cannot be empty in      /mounted-storage/home98a/sub009/sc61374-HGPS/sitakalyanam.com/newsita/php4upload.class.php        on line 86</p>
  </blockquote>
  
  <p>well line 86 piece of code i am attaching..</p>
  
  <pre><code>    function _doSafeUpload ()
  {
      preg_match('/\.([a-zA-Z]+?)$/', $this-&gt;_params['name'], $matches);
      if (exif_imagetype($this-&gt;_params['tmp_name']) &amp;&amp;       in_array(strtolower($matches[1]), $this-&gt;_types))
      {
          if ($this-&gt;_params['size'] &gt; $this-&gt;_maxsize)
              $this-&gt;_errors[] = $this-&gt;_lang['E_SIZE'];
          else
              $this-&gt;_im_status = true;
  
          if ($this-&gt;_im_status == true)
          {
              $ext = substr($this-&gt;_params['name'], -4);
              $this-&gt;new_name = md5(time()).$ext;
  
              move_uploaded_file($this-&gt;_params['tmp_name'], $this-        &gt;_upload_dir.$this-&gt;new_name);
  
          $this-&gt;imgurl =$this-&gt;new_name;
  
          //$this-&gt;imgurl = .$this-&gt;new_name;
  
  
          }
      }
      else
          $this-&gt;_errors[] = $this-&gt;_lang['E_TYPE'];
  }
  </code></pre>
  
  <p>i dont want to show the error getting displayed in my webpage for my user. instead      i want to show them or intimate them that they have not selected any file for uploading.</p>
  
  <p>here i am uploading the complete code.but no errors if uploading files are selected     error comes only if no file is choosen for uploading</p>
  
  <pre><code>    &lt;?php
     /*
  
    - PHP4 Image upload script
  
    */
  
     class imageupload
    {
    //pblic variables
      var $path = '';
      var $errorStr = '';
      var $imgurl = '';
  
      //private variables
      var $_errors = array();
      var $_params = array();
      var $_lang = array();
      var $_maxsize = 1048576;
  
      var $_im_status = false;
  
      //public methods
      function imageupload ()
   {
      //require 'photouploadconfig.php';
  
      if($_GET['Choice']=="1")
      {           
     require 'Photouploddir1.php';
     }
     elseif ($_GET['Choice']=="2")
     {
     require 'Photouploddir2.php';
     }
     elseif ($_GET['Choice']=="3") 
     {
     require 'Photouploddir3.php';
     }
     elseif ($_GET['horoschoice']=="1")
    {
    require 'horosuploaddir.php';
    }
    elseif ($_GET['videoChoice']=="5")
    {
    require 'videouploaddir.php';
    }
  
  
          $this-&gt;_types = $types;
          $this-&gt;_lang = $lang;
      $this-&gt;_upload_dir = $upload_dir;
      $this-&gt;_maxsize = $maxsize;
  
          $this-&gt;path = $PHP_SELF;
  
          if (is_array($_FILES['__upload']))
          {
              $this-&gt;_params = $_FILES['__upload'];
              if (function_exists('exif_imagetype'))
                  $this-&gt;_doSafeUpload();
          else
                  $this-&gt;_doUpload();
  
              if (count($this-&gt;_errors) &gt; 0)
                  $this-&gt;_errorMsg();
          }
       }
  
      function allowTypes ()
      {
          $str = '';
          if (count($this-&gt;_types) &gt; 0) {
              $str = 'Allowed types: (';
              $str .= implode(', ', $this-&gt;_types);
              $str .= ')';
          }
  
          return $str;
      }  
  
         // private methods
      function _doSafeUpload ()
      {
          preg_match('/\.([a-zA-Z]+?)$/', $this-&gt;_params['name'], $matches);
          if (exif_imagetype($this-&gt;_params['tmp_name']) == exif_imagetype($this-           &gt;_params['']))
          { 
            print '&lt;script type="text/javascript"&gt;'; 
                print 'alert("Opps! You Have Not Choosen Any Photos For Uploading.Kindly          Select Choose File Tab For Uploading.")'; 
                 print '&lt;/script&gt;'; 
                 print "&lt;script&gt;";
                 print " self.location='photoupload.php';";
                 print "no photo uploaded";
                    print "&lt;/script&gt;";
          }  
          if (exif_imagetype($this-&gt;_params['tmp_name']) &amp;&amp; in_   a      rray(strtolower($matches[1]), $this-&gt;_types))
          {
              if ($this-&gt;_params['size'] &gt; $this-&gt;_maxsize)
              $this-&gt;_errors[] = $this-&gt;_lang['E_SIZE'];
          else
              $this-&gt;_im_status = true;
  
          if ($this-&gt;_im_status == true)
          {
              $ext = substr($this-&gt;_params['name'], -4);
              $this-&gt;new_name = md5(time()).$ext;
  
                  move_uploaded_file($this-&gt;_params['tmp_name'], $this-&gt;_u        pload_dir.$this-&gt;new_name);
  
              $this-&gt;imgurl =$this-&gt;new_name;
  
          //$this-&gt;imgurl = .$this-&gt;new_name;
  
  
          }
              }
         else
          $this-&gt;_errors[] = $this-&gt;_lang['E_TYPE'];
                  } 
  
          function _doUpload ()
         {
      preg_match('/\.([a-zA-Z]+?)$/', $this-&gt;_params['name'], $matches);
      if(in_array(strtolower($matches[1]), $this-&gt;_types))
      {
              if ($this-&gt;_params['size'] &gt; $this-&gt;_maxsize)
              $this-&gt;_errors[] = $this-&gt;_lang['E_SIZE'];
          else
              $this-&gt;_im_status = true;
  
          if ($this-&gt;_im_status == true)
          {
              $ext = substr($this-&gt;_params['name'], -3);
                  $this-&gt;new_name = md5(time()).$ext;
  
                  move_uploaded_file($this-&gt;_params['tmp_name'], $this-&gt;_u          pload_dir.$this-&gt;new_name);
  
                  $this-&gt;imgurl = ''.$this-&gt;new_name;
  
      //$this-&gt;imgurl = ''.$this-&gt;_upload_dir.''.$this-&gt;new_name;
      //$this-&gt;imgurl = ''.$this-&gt;new_name;
  
                  //$this-&gt;imgurl = $this-&gt;_upload_dir.'/'.$this-&gt;new_name;
  
  
  
              }
          }
      else
          $this-&gt;_errors[] = $this-&gt;_lang['E_TYPE'];
          }   
  
             function _errorMsg()
             { 
           $this-&gt;errorStr = implode('&lt;br /&gt;', $this-&gt;_errors);
             }
             }
  
             ?&gt;
  </code></pre>