<?
 error_log
('accept array is set');
/**
 * This is a sample file upload handler script that demonstrates how files
 * can be accepted or rejected based on it's extension.
 *
 * You can define a list of allowed types in the $allowed array, only files
 * with matching extensions will be accepted. Alternatively you can define 
 * a list of file types to be rejected using the $reject array. Any file with
 * a matching extension will be rejected while all other file types will be
 * considered safe.
 *
 * If both $allow and $reject are defined, $accept takes precedence. Please use
 * lower case extensions.
 *
 */
?>
<html>
<head><title>Rad Upload</title></head>


<body  bgcolor="FFFFCC">
<table border="1" cellpadding="5" width="100%" align="center">
<tr><td colspan="3" bgcolor="#0066cc"><font color="#FFFFCC" size="+1" align="center">Files Uploaded</font></td></tr>
<tr  bgcolor="#ffff00"><td style="font-size: 110%;"><nobr>File Name</nobr></td>
    <td style="font-size: 110%"  align="right"><nobr>File size</nobr></td>
    <td style="font-size: 110%"  align="right"><nobr>Status</nobr></td>
    </tr>
<?

/*
 * SET THE SAVE PATH by editing the line below. Make sure that the path
 * name ends with the correct file system path separator ('/' in linux and
 * '\\' in windows servers (eg "c:\\temp\\uploads\\" )
 */

$save_path="";    

/**
 * enter a list of file extensions that should be rejected.
 */
$reject = array('exe','com','bat','dll','sh','php','cgi','class');

/**
 * If $accept array is defined only files with matching extensions
 * are allowed.
 *
 * $accept = array('gif');
 */
 
 

 
$file $_FILES['userfile'];
$k count($file['name']);


for(
$i=$i $k $i++)
{
    if(
$i %2)
    {
        echo 
'<tr bgcolor="#FFFF99"> ';
    }
    else
    {    
        echo 
'<tr>';
    }
    
    echo 
'<td align="left">' $file['name'][$i] ."</td>\n";
    echo 
'<td align="right">' $file['size'][$i] ."</td>\n";

    
    
$fileName basename($file['name'][$i]);
    
$parts split('\.',$fileName);
    
$ext strtolower($parts[count($parts)-1]);
    
    
    if(
is_array($accept))
    {
        
        if(
in_array($ext,$accept))
        {
            
/**
             * the file is of a type that is listed in the $accept array
             * let's accept it and save it to the hard disk if the 
             * save_path is set
             */
            
echo "<td>Accepted</td>";
            if(isset(
$save_path) && $save_path!="")
            {
                
move_uploaded_file($file['tmp_name'][$i], $save_path $name[count($name)-1]);
            }
        }
        else
        {
            echo 
"<td>Rejected</td>";
        }
    }
    else if(
is_array($reject))
    {
        
/* 
        * we will inspect the file extension and reject the file, 
        * should we find it's extension listed in the $rejects
        * array.
        */


        
if(in_array($ext,$reject))
        {
            echo 
"<td>Rejected</td>";
        }
        else
        {
            echo 
"<td>Accepted</td>";
            if(isset(
$save_path) && $save_path!="")
            {
                
move_uploaded_file($file['tmp_name'][$i], $save_path $name[count($name)-1]);
            }
        }
    }
    echo 
"</tr>\n";
    
}


if(! isset(
$save_path) || $save_path =="")
{
    echo 
'<tr><td colspan=3 align="left">Files have not been saved, please edit upload.php to match your configuration</td></tr>';
}
echo 
"<tr><td colspan=3>Top level folder hint : $userfile_parent</td></tr>";
?>
</table>
<p>&nbsp;</p>

<p style="text-align:center; font-size: 90%">Sample  PHP Upload handler provided by
 <a href="http://www.radinks.com/?dn">Rad Inks</a></p>
 <p>&nbsp;</p>
<p style="text-align:center; font-size: 90%">have you seen our <a href="http://www.radinks.com/sftp/?dn">Secure FTP Applet</a> or &nbsp;
our <a href="http://www.radinks.com/mms/?dn">Multimedia Messaging Solution</a>?</p>

</body>
</html>