how to read .zip file in php
-
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 ?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 - useis_resource
on the result. -
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 - useis_resource
on the result.