title: php upload image and documents like pdf,doc,ppt
body: <p>hello all i have been working on a web page where users can upload images and applications like word file,ppt,pdf,excel file etc.. but i am not sure about my code can any one please suggest me a better and more secure way to deal with this . i want to do mime check not from the client side but from the server side . and also i want the maximum file size to be uploaded to be 7 mb .
  this is my code can any one please suggest me anything </p>
  
  <pre><code> $allowedExts = array("pdf", "doc", "docx","png","jpg","jpeg","gif");
  $extension = end(explode(".", $_FILES["uploadpic"]["name"]));
  if (($_FILES["uploadpic"]["type"] == "application/pdf") ||
  ($_FILES["uploadpic"]["type"] == "application/msword") || 
   ($_FILES["uploadpic"]["type"] 
   == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") ||  
   ($_FILES["uploadpic"]["type"] == "image/png") ||
     ($_FILES["uploadpic"]["type"]=="image/jpeg") || 
     ($_FILES["uploadpic"]["type"] == "image/jpg") 
      &amp;&amp; ($_FILES["uploadpic"]    ["size"] &lt; 7340032) &amp;&amp; 
     in_array($extension,  $allowedExts))
  {
    if ($_FILES["uploadpic"]["error"] &gt; 0)
    {
  echo 'error';
  exit;
    }
    else
    {
     $filetname=$_FILES ['uploadpic']['tmp_name'];
      $filename=$_FILES ['uploadpic']['name'];
     $insert=move_uploaded_file($filetname,"folder/$filename"); 
     $insertpostsandpic=mysql_query("insert into `database` (`id`,`name`,`date`) 
      values   ('$id','$filename','$time')");
       echo 'sucess'; exit;
       }
        } else{
     echo 'fail';
     exit;
        }
  </code></pre>