I am trying to uncompress a binary file and then uncompress it to test whether the compresssion is working. However the 'uncompressed' file has the same data as the 'compressed' file. As though the uncompression never happened. I have listed code below. thanks in advance:
//compressing
//read file
$filename = 'tocompress/tocompress'.$number_input.'.bin';
$contents=fread($fp,filesize($filename));
fclose($fp);
//compress file
$compressing = gzcompress($contents , '0');
//write to file
$fp = fopen('compressed/compressed'.$number_input.'.bin', 'wb');
fwrite($fp, $compressing);
fclose($fp);
//uncompressing
//read file
$uncompfilename='compressed/compressed'.$number_input.'.bin';
$fp=fopen($uncompfilename,'rb');
$uncompresscontents=fread($fp,filesize($uncompfilename));
fclose($fp);
//uncompress file
$uncompressing = gzuncompress($uncompresscontents);
//write to file
$fp = fopen('uncompressed/uncompressed'.$number_input.'.bin', 'wb');
fwrite($fp, $uncompresscontents);
fclose($fp);