0

I need to do an aplication to makes the user download a lot of pictures in the server choosing some criterias and only in one archive. i tried with php and pclzip.lib and zipstream libraries found on web, but none of the two methods work. with pclzip i only can compress 3Mb and with zipstream library in the middle of the download it fails with a 25MB size. I don´t know how many archives the user will need to download but now i have around 700 archives and 75MB. Is there another way to make this application work or has anyone had similar problems with this libraries and solved it. Here's some more specifications: remote server iis, php. thanks and sorry for my english

2 Answers2

1

After some time I've found the way using

 ini_set('max_execution_time', 1200);
 ini_set("memory_limit","500M");

And the library ZipStream. Also, I've changed the PHP memory limit in the PHP server because my file is really big.

Gander
  • 1,854
  • 1
  • 23
  • 30
0

I've used pclzip before and this code works:

if ($this->extension == 'zip') {
    $this->archive = new PclZip($orgPath);

    if ($this->archive->extract(PCLZIP_OPT_PATH, $newPath) == 0) {
        die("Error : " . $this->archive->errorInfo(true));
    }
}

But I think that's not your problem. It sounds like not enough RAM for PHP or not enough time.

If that's your problem, you can fix it with

set_time_limit(0);   // 0 = no time limit
ini_set('memory_limit', '300M');  // Increases memory for PHP to 300M

That works for me on Apache (I'm not shure, but does ini_set Work on your system?)

waXve
  • 792
  • 2
  • 9
  • 30
  • I'm using this `code`ini_set('max_execution_time', 300); ini_set("memory_limit","100M"); at the begin of my script. When i was starting with this i have seen the out of memory message , but now only get this error: The page cannot be displayed because an internal server error has occurred and an incomplete zip archive.why? – Marisol patito May 02 '12 at 22:14
  • error_reporting(-1); ini_set('display_errors', '1'); ini_set("display_startup_errors", true); ini_set("display_errors", true); – waXve May 03 '12 at 10:46
  • Thank you for your interesting. I've just tried displaying all error but doesn't work. the internal server error message again. – Marisol patito May 03 '12 at 16:13
  • have you an .htaccess file? That could be the reason for that too. If you have there a mistake, your server throws a 500 - internal server error. – waXve May 03 '12 at 16:20
  • No i don't I'm using a hosting server so I think I can't access it or I don´t know how – Marisol patito May 03 '12 at 18:06
  • can you give me your code (eg. Public Dropbox link, ftp Server) so that I can test this on my webserver? I think that would be better than if you post it here. That might be to much. – waXve May 03 '12 at 19:19
  • Hi, here's the link [link](https://www.dropbox.com/s/lfltgibq0lefikc/MESdescargaimagenes.php) I hope you can help me. The dir that I want to download is "fotografias". Thanks a lot – Marisol patito May 04 '12 at 15:27
  • Hi, it's really not easy to read that code, because I don't understand your language ;-), but I think, I got the idea. I am not sure, if this is the mistake. As I understood your code, you never close the zip file. Normaly, that shouldn't be the reaseon for a 500, but it's a mistake. Please try it out what happens, when you close the archive. – waXve May 04 '12 at 15:51
  • yeah, i thought so. There's nothing about close the zip file in pclzip library documentation [here] (http://www.phpconcept.net/pclzip/user-guide/18), isn't it? – Marisol patito May 04 '12 at 16:44