: Is there a zip function in php that reads in a zip file and parses out the
: embedded files?  On www.php.net they mention one that they say needs to be
: compiled in, but in my php.ini file there is a line extension=php_zip.dll
: that I uncommented.  What are the functions for that php_zip.dll?  (it would
: be nice if the php gurus could include a snippet of code)

Yes, you do have to have the ZZIPLIB (http://zziplib.sourceforge.net/) libs compiled 
in to your PHP
installation.. The php_zip.dll file is for ?indows servers, can't help you there.. If 
you are using Linux but
don't want to recompile PHP with ZZIPLIB support, you can use zip and unzip included 
with Linux.. I have put
an example below..

This is from a gallery that will accept single images or zip files for upload:

function getImage( $image, $uploadDir, $newName = false )
{
        global ${ $image }, ${ $image . "_name" }, ${ $image . "_size" }, ${ $image . 
"_type" }, $zipFile;

        include( "header.html" );
        if( $zipFile == "checked" )
        {
                $name = basename( ${ $image . "_name" } );
                echo( "<div class=\"bodyTextRed\">Uploaded ZIP file $name to $uploadDir
successfully.</div><br>" );
                copy( ${ $image }, "$uploadDir/$name" );
                @system( "/usr/bin/unzip -oj $uploadDir/$name -d $uploadDir 
&>/dev/null" );
                unlink( "$uploadDir/$name" );
        }
        else
        {
                $name = basename( ${ $image . "_name" } );
                echo( "<div class=\"bodyTextRed\">Uploaded single image $name to 
$uploadDir
successfully.</div><br>" );
                $size = ${ $image . "_size" };
                $type = ${ $image . "_type" };
                $name = strtolower( $name );
                $name = str_replace( " ", "_", $name );

                if( $newName )
                {
                        if( eregi( "\.jpg", $name ) or eregi( "\.jpeg", $name ) ) $ext 
= ".jpg";
                        else $ext = ".gif";
                        $name = $newName . $ext;
                }

                @copy( ${ $image }, "$uploadDir/$name" );
                @chown( "$uploadDir/$name", "bob" );
                return $name;
        }
}

I have the user check a box indicating a zip file but the script could be made to 
check that automatically and
run unzip or tar or whatever program was needed automatically..

Hope it helps,

Bob


____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to