Skip to content

Instantly share code, notes, and snippets.

@gabyfle
Created April 27, 2019 22:21
Show Gist options
  • Save gabyfle/c8e556ec054f0dc4bb92e35c39c93310 to your computer and use it in GitHub Desktop.
Save gabyfle/c8e556ec054f0dc4bb92e35c39c93310 to your computer and use it in GitHub Desktop.
Checks if an uploaded file is a .zip one.
<?php
function isZip(string $tmp, string $name)
{
$extension = pathinfo($name, PATHINFO_EXTENSION);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_file($finfo, $tmp);
return $type === 'application/zip' && $extension === 'zip';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment