title: How to prevent uploading fake images?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6484307/how-to-check-if-an-uploaded-file-is-an-image-without-mime-type">How to check if an uploaded file is an image without mime type?</a><br>
    <a href="https://stackoverflow.com/questions/13972714/uploading-processing-storing-and-delivering-user-provided-files-and-images">uploading, processing, storing and delivering user-provided files and images</a>  </p>
  </blockquote>
  
  
  
  <p>i have image sharing script, i made half of it.
  the user can rename any php or cgi file to .jpg and upload it and it upload succfully</p>
  
  <p>How to prevent uploading such fake images?</p>
  
  <p>here is my way to check the file type</p>
  
  <pre> $userfile_type = $_FILES['file']['type']; </pre>
  
  <p>and when i rename php file to php.jpg it can be uploaded easly.</p>