SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Evangelist hessodreamy's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    522
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Uncompress compressed string

    I've got a script which fetches zipped content from a web page. Under normal circumstances the browser would donwload this as a zip file, but for my script the remote server just returns the compressed string, and I'm trying to figure out how to uncompress it. Apparently it's compressed using PKzip if that's any help.

    I've tried just writing it to a file
    Code:
    $fh = fopen("zipfile.zip","w");
    fwrite($fh,$zippedString);
    But when I try to open the zip file (after writing it) it appears to be invalid.

    I've tried gzuncompress() and gzinflate(), eg
    Code:
    echo gzinflate($zippedString);
    but it still outputs gibberish.

    Any ideas?

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Evangelist hessodreamy's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    522
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gvre View Post
    I've looked through the functions there, but they all seem to deal with a zipped file, rather than the actual zipped contents. What I've got is the zipped output from a remote server.

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you post the url of the zip file and your script's code?

  5. #5
    SitePoint Evangelist hessodreamy's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    522
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Have re-visited this problem and got it sussed.
    I think the main problem I had was that I was grabbing a stream straight from a website, and part of this stream was the headers. I needed to remove the headers and then the content of the response was a valid zip file.
    I unzipped it using the pclzip class. I'm not sure whether the gzinflate would have been correct or incorrect for zipped content, but I think the headers were the main problem.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •