PHP File Uploader Image Filter
<p>Alright, so I found an upload script, and added adjustments to fit with my sessions.  It echos out the image if the session is not logged in, but if the session IS logged in, it shows the file uploader.  The thing is, someone can upload a harmful PHP script to this, I just want this to be for images.  Any suggestions that will make my code images only?  I tried added filters, but this does not work.  Here is my code:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Upload your own picture of Bouncy!&lt;/title&gt;
&lt;/head&gt;
&lt;style type='text/css'&gt;
body {
background-image:url('../membership/sitebg.png');
background-repeat:repeat-x;
background-color:#ffffff;
}

a {
color: #093D03;
text-shadow:0px 0px 5px #ffffff;
}

a:visited {
color: #093D03;
}

a:active {
color: #093D03;
}

a:hover {
color: #1AFF00;
}
&lt;/style&gt;
&lt;?php
session_start();

if ($_SESSION['loggedin'] == true) 
{
echo "&lt;br /&gt;";
echo "&lt;br /&gt;";
echo "&lt;center&gt;&lt;font face='arial'&gt;Welcome to the funny picture uploader,&lt;b&gt; ".$_SESSION['username'];
echo "&lt;/b&gt;&lt;br /&gt;&lt;a href='http://x.org/membership/logout.php'&gt;Logout&lt;/a&gt; | &lt;a href='#'&gt;More&lt;/a&gt; | &lt;a href='http://x.org'&gt;Home&lt;/a&gt;";
echo "&lt;br /&gt;";
echo "&lt;br /&gt;";
                    $max_no_img=1; // Maximum number of images value to be set here
                    echo "&lt;form method=post action='' enctype='multipart/form-data'&gt;";
                    echo "&lt;table border='0' width='400' cellspacing='0' cellpadding='0' align=center&gt;";
                    for($i=1; $i&lt;=$max_no_img; $i++)                             {
                    echo "&lt;tr&gt;&lt;td&gt;Images $i&lt;/td&gt;&lt;td&gt;
                    &lt;input type=file name='images[]' class='bginput'&gt;&lt;/td&gt;&lt;/tr&gt;";
                                                                                 }
                          echo "&lt;tr&gt;&lt;td colspan=2 align=center&gt;&lt;input type=submit value='Add Image'&gt;&lt;/td&gt;&lt;/tr&gt;";
                          echo "&lt;/form&gt; &lt;/table&gt;";
      while(list($key,$value) = each($_FILES['images']['name']))
                                                                                                      {
          //echo $key;  
          //echo "&lt;br&gt;";
          //echo $value;
          //echo "&lt;br&gt;";
      if(!empty($value)){   // this will check if any blank field is entered
      $filename =rand(100000000000000,10000000000000000000).$value;    // filename stores the value

      $filename=str_replace(" ","-",$filename);// Add _ inplace of blank space in file name, you can remove this line

      $add = "pictures/$filename";   // upload directory path is set
      //echo $_FILES['images']['type'][$key];     // uncomment this line if you want to display the file type
      //echo "&lt;br&gt;";                             // Display a line break
      copy($_FILES['images']['tmp_name'][$key], $add); 
      echo "&lt;center&gt;&lt;b&gt;Your picture will be stored at:&lt;/b&gt;&lt;/center&gt; ";
      echo "&lt;center&gt;&lt;a href='http://bouncygames.org/$add'&gt;Click here to view your image!&lt;/a&gt;&lt;/center&gt;";
          //  upload the file to the server
      chmod("$add",0777);                 // set permission to the file.
        }                                                                                               }
} else {
echo "&lt;br /&gt;&lt;center&gt;&lt;img src='sorry.png'&gt;&lt;br /&gt;
&lt;a href='x'&gt;&lt;img src='button-to-join.png'&gt;&lt;/a&gt;
&lt;/center&gt;";
}
?&gt;
</code></pre>

<p>My question:  <strong>How can I make this ONLY upload images?</strong></p>
