var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
PHP and .gz ! Need Help!!
I need help with .gz for a php script.
I have uploaded a file.gz in my server. Its more than 18 mb in size and 25mb when unzipped.
Its wud be really a pain if I go for uploading each and every file one by one without .gz.
Now, I want a php script that will extract, for e.g, the file.txt.gz to file.txt in the same location of the server.
Can anyone help me with the script pls.
See the comments here: http://us2.php.net/zlib
Hello, I found this script from ur given url :
function uncompress( $srcFileName, $dstFileName, $fileSize )
// getting content of the compressed file
$zp = gzopen( $srcFileName, "r" );
$data = fread ( $zp, $fileSize );
gzclose( $zp );
// writing uncompressed file
$fp = fopen( $dstFileName, "w" );
fwrite( $fp, $data );
fclose( $fp );
And I used the function this way :
uncompress("file.txt.gz", "file.txt", filesize("file.txt.gz"));
But unfortunately, it just copied the original file to file.txt without uncompressing it.
The uncompressed file should have been more than 24mb in size. but its still the same (16mb).
Is there anyth wrong in the codes?
Try using gzread() instead of fread().
I got it! Thanks man!
Actually the variable filesize is the size of the file in extracted form.
it worked fine!