select zip file

<html>
<head>
    <title> zip archive file test </title>
</head>

<body>

<p>
<?PHP

if( $_FILES ){

    
/* check extension */
    
$tmp pathinfo($_FILES[name][name]);
    
    if( 
strcasecmp($tmp[extension], "zip") != )
        
unlink$_FILES[name][tmp_name] );
        
    else {
    
        
/* print file name */
        
echo "<h3>Uploaded File: "$_FILES[name][name]. "</h3>\n\n";

        
/* open zip archive */
        
$src zip_open($_FILES[name][tmp_name]);

        
/* if failed */
        
if( !$src ) {
            echo 
"<p>this is not valid zip archive</p>\n";
            
unlink$_FILES[name][tmp_name] );
            exit;
        }

        echo 
"<ol>\n";
        
/* print zip_entry */
        
while( $entry zip_read($src) ){
            echo 
"\t<li>\n\t<ul>\n";
            
            
            echo 
"\t\t<li>Name: " zip_entry_name($entry) . "</li>\n";
            echo 
"\t\t<li>Actual Filesize: " zip_entry_filesize($entry) . "</li>\n";
            echo 
"\t\t<li>Compressed Size: " zip_entry_compressedsize($entry) . "</li>\n";
            echo 
"\t\t<li>Compressed Method:" zip_entry_compressionmethod($entry) . "</li>\n";

            echo 
"\t</ul>\t</li>\n";
        }
        echo 
"</ol>";
        
zip_close($src);
        
unlink$_FILES[name][tmp_name] );
    }
}

?>
</p>

<p>select zip file</p>

<form method="post" action="<?=$_SERVER[PHP_SELF]?>" encType="multipart/form-data">
<input type="file" name="name">
<input type="submit">
</form>

<?PHP show_source(__FILE__); ?>

</body>
</html>