Skip to content

Instantly share code, notes, and snippets.

@halilim
Created September 1, 2013 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halilim/6406548 to your computer and use it in GitHub Desktop.
Save halilim/6406548 to your computer and use it in GitHub Desktop.
GZip a File
<?php
if (!empty($_POST) && isset($_FILES['file'])
&& $_FILES['file']['error'] == UPLOAD_ERR_OK
) {
header(
'Content-Disposition: attachment; filename="'
. $_FILES['file']['name'] . '.gz";'
);
echo gzencode(file_get_contents($_FILES['file']['tmp_name']));
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GZip File</title>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="">
<input type="file" name="file" />
<input type="submit" name="send" value="GZip File" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment