Asked  2 Years ago    Answers:  5   Viewed   84 times
function uncompress($srcName, $dstName) {
    $sfp = gzopen($srcName, "rb");
    $fp = fopen($dstName, "w");

    while ($string = gzread($sfp, 4096)) {
        fwrite($fp, $string, strlen($string));

I tried this code but this does not work, I get:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.



Try this found here

//This input should be from somewhere else, hard-coded in this example
$file_name = '2013-07-16.dump.gz';

// Raising this value may increase performance
$buffer_size = 4096; // read 4kb at a time
$out_file_name = str_replace('.gz', '', $file_name); 

// Open our files (in binary mode)
$file = gzopen($file_name, 'rb');
$out_file = fopen($out_file_name, 'wb'); 

// Keep repeating until the end of the input file
while (!gzeof($file)) {
    // Read buffer-size bytes
    // Both fwrite and gzread and binary-safe
    fwrite($out_file, gzread($file, $buffer_size));

// Files are done, close files
Wednesday, August 17, 2022

I found this topic here

Someone sais:

I've had this problem before. Make sure you upload your file in ASCII not Binary. Sometimes, with some FTP servers, you have to set this manually. Also try converting your newlines to "n" in your text editor. Lemme know which editor you're using and I'll give you more specific instructions.

And someone solved it : I solve this problem using notepad++ ( Open php files with notepad++ and in Format menu chose encode in utf-8 without BOM and save it.

Hope this helps to

Tuesday, August 30, 2022

I get 42 bytes on .NET as well. I suspect you're using an old version of .NET which had a flaw in its compression scheme.

Here's my test app using your code:

using System;
using System.IO;
using System.IO.Compression;
using System.Text;

class Program
    static void Main(string[] args)
        var uncompressed = Encoding.UTF8.GetBytes("Mary had a little lamb");
        var compressed = GZIPCompress(uncompressed);

    static byte[] GZIPCompress(byte[] data)
        using (var memoryStream = new MemoryStream())
            using (var gZipStream = new GZipStream(memoryStream, 
                gZipStream.Write(data, 0, data.Length);

            return memoryStream.ToArray();



This is exactly the same as the Java data.

I'm using .NET 4.5. I suggest you try running the above code on your machine, and compare the results.

I've just decompressed the base64 data you provided, and it is a valid "compressed" form of "Mary had a little lamb", with 22 bytes in the uncompressed data. That surprises me... and reinforces my theory that it's a framework version difference.

EDIT: Okay, this is definitely a framework version difference. If I compile with the .NET 3.5 compiler, then use an app.config which forces it to run with that version of the framework, I see 137 bytes as well. Given comments, it looks like this was only fixed in .NET 4.5.

Monday, November 21, 2022

Unless you have a very good reason to not do so, you want to put the load of compression on the web servers since the app servers are already busy at doing other things. To use mod_weblogic together with mod_deflate, have a look at this post.

Sunday, September 25, 2022

Usually when questions like this are asked some effort needs to be shown. So please take consideration to state the exact problem with at least some effort on what you have attempted next time. To get you started here is an example using the XML package and applying XPath along with strsplit to grab the desired result.

doc <- htmlParse("")
x <- xpathSApply(doc, "//td[@style='text-align: justify']/text()[preceding-sibling::br][1]",
    function(X) { strsplit(xmlValue(X), ': ')[[1]][2]
# [1] "Uninfected"
Wednesday, December 21, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages