Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. how to read .zip file in php

how to read .zip file in php

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    udch
    wrote on last edited by
    #1

    I use this but it is not working "; echo "Compressed Size: " . zip_entry_compresedsize($zipFile) . "
    "; echo "Real Size: " . zip_entry_filesize($zilFile) . "
    "; } ?> do you have any idea how to read this zip file ?

    G 1 Reply Last reply
    0
    • U udch

      I use this but it is not working "; echo "Compressed Size: " . zip_entry_compresedsize($zipFile) . "
      "; echo "Real Size: " . zip_entry_filesize($zilFile) . "
      "; } ?> do you have any idea how to read this zip file ?

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      I hope you didn't paste that in, because it looks like there's a mistake on almost every line. I believe the main problem is trying to read the zip file directly from the remote address. Try taking a copy of the file, and open that instead:

      $file = "http://www.nseindia.com/content/historical/EQUITIES/2010/APR/cm12APR2010bhav.csv.zip";
      $tmp_file = "tmp/tmp.zip";

      copy($file, $tmp_file);
      $zip = zip_open($tmp_file);
      while($zipFile = zip_read($zip))
      {
      ...

      You should check that zip_open returns a resource before trying to read from it too - use is_resource on the result.

      U 1 Reply Last reply
      0
      • G Graham Breach

        I hope you didn't paste that in, because it looks like there's a mistake on almost every line. I believe the main problem is trying to read the zip file directly from the remote address. Try taking a copy of the file, and open that instead:

        $file = "http://www.nseindia.com/content/historical/EQUITIES/2010/APR/cm12APR2010bhav.csv.zip";
        $tmp_file = "tmp/tmp.zip";

        copy($file, $tmp_file);
        $zip = zip_open($tmp_file);
        while($zipFile = zip_read($zip))
        {
        ...

        You should check that zip_open returns a resource before trying to read from it too - use is_resource on the result.

        U Offline
        U Offline
        udch
        wrote on last edited by
        #3

        Thank you very much for your help code is working.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups