[Solved] when upload zip folder validate that only .jpg,.png files will save inside zip folder +php [closed]


welcome to SO, if you like to get a nice answer and don’t want to get downvoted i suggest you to make a nice question and not provide only your code and wait that someone fix your stuff.

besides that, you can use the php ZipArchive functions to get your work done

http://php.net/manual/en/class.ziparchive.php

// validate against zip folder
// ...

$zip = new ZipArchive(); 
$zip->open($file['temp_dir']); 

if( $zip === true )
{
    $invalid = false;
    for( $i = 0; $i < $za->numFiles; $i++ ){ 
        $stat = $za->statIndex( $i ); 
        if( !in_array(strtolower(pathinfo(basename($stat['name'] )), PATHINFO_EXTENSION), array('jpg','png')) )
        {
            $invalid = true;
            break;
        }
    }

    if( $invalid )
    {
        // error other files then jpg and png
    } else {
        // ok!
    }

} else {
    // error open zip file
}

1

solved when upload zip folder validate that only .jpg,.png files will save inside zip folder +php [closed]