Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6736 > unrolled thread
| Started by | Supriya <singla.supriya88@gmail.com> |
|---|---|
| First post | 2012-08-07 23:40 -0700 |
| Last post | 2012-08-12 19:25 +0200 |
| Articles | 8 — 7 participants |
Back to article view | Back to comp.lang.php
problem in creating Zip file Supriya <singla.supriya88@gmail.com> - 2012-08-07 23:40 -0700
Re: problem in creating Zip file Doug Miller <doug_at_milmac_dot_com@example.com> - 2012-08-08 14:18 +0000
Re: problem in creating Zip file Christoph Becker <cmbecker69@gmx.de> - 2012-08-08 16:37 +0200
Re: problem in creating Zip file Jerry Stuckle <jstucklex@attglobal.net> - 2012-08-08 11:25 -0400
Re: problem in creating Zip file Doug Miller <doug_at_milmac_dot_com@example.com> - 2012-08-08 17:46 +0000
Re: problem in creating Zip file salil.ag@gmail.com - 2012-08-08 21:37 -0700
Re: problem in creating Zip file "J.O. Aho" <user@example.net> - 2012-08-09 07:09 +0200
Re: problem in creating Zip file "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-08-12 19:25 +0200
| From | Supriya <singla.supriya88@gmail.com> |
|---|---|
| Date | 2012-08-07 23:40 -0700 |
| Subject | problem in creating Zip file |
| Message-ID | <1592f3dd-f681-4100-b6b4-e1684b06322c@googlegroups.com> |
Hi All
i m trying to create a Zip file of 1 folder which contains 2 folders and 33 files but the resulted zip file only contains 21 file and 1 folder.And when i open the files of zip folder it says files r corrupted.
Here is my code:
Plz help me to find out what is wrong there...
<?php
include("variable.php");
ini_set("max_execution_time", 18000);
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open($outputfoldername . ".zip", ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($outputfoldername . "/"));
// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}
// close and save archive
$zip->close();
echo "Archive created successfully.";
?>
Thanks
Regards Supriya
[toc] | [next] | [standalone]
| From | Doug Miller <doug_at_milmac_dot_com@example.com> |
|---|---|
| Date | 2012-08-08 14:18 +0000 |
| Message-ID | <XnsA0A968AAF5B8Edougmilmaccom@88.198.244.100> |
| In reply to | #6736 |
Supriya <singla.supriya88@gmail.com> wrote in news:1592f3dd-f681-4100-b6b4-
e1684b06322c@googlegroups.com:
> Hi All
> i m trying to create a Zip file of 1 folder which contains 2 folders and 33 files but the
resulted zip file only contains 21 file and 1 folder.And when i open the files of zip folder it
says files r corrupted.
>
> Here is my code:
> Plz help me to find out what is wrong there...
>
> <?php
>
> include("variable.php");
>
> ini_set("max_execution_time", 18000);
Had you considered that this may not be enough time?
[toc] | [prev] | [next] | [standalone]
| From | Christoph Becker <cmbecker69@gmx.de> |
|---|---|
| Date | 2012-08-08 16:37 +0200 |
| Message-ID | <jvttio$ppi$1@speranza.aioe.org> |
| In reply to | #6740 |
Doug Miller wrote:
> Supriya wrote:
>> ini_set("max_execution_time", 18000);
>
> Had you considered that this may not be enough time?
I suppose 5 h should be pretty much enough for creating a ZIP file. But
indeed changing the max_execution_time might fail (e.g. when PHP runs in
safe mode). However, if the script outputs "Archive created
successfully.", the execution time can't be the problem.
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-08-08 11:25 -0400 |
| Message-ID | <jvu0dd$6or$1@dont-email.me> |
| In reply to | #6741 |
On 8/8/2012 10:37 AM, Christoph Becker wrote:
> Doug Miller wrote:
>> Supriya wrote:
>>> ini_set("max_execution_time", 18000);
>>
>> Had you considered that this may not be enough time?
>
> I suppose 5 h should be pretty much enough for creating a ZIP file. But
> indeed changing the max_execution_time might fail (e.g. when PHP runs in
> safe mode). However, if the script outputs "Archive created
> successfully.", the execution time can't be the problem.
>
Are you sure you CAN change the max execution time? Many shared hosting
environments don't allow it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Doug Miller <doug_at_milmac_dot_com@example.com> |
|---|---|
| Date | 2012-08-08 17:46 +0000 |
| Message-ID | <XnsA0A98C2E6D525dougmilmaccom@88.198.244.100> |
| In reply to | #6741 |
Christoph Becker <cmbecker69@gmx.de> wrote in news:jvttio$ppi$1@speranza.aioe.org:
> Doug Miller wrote:
>> Supriya wrote:
>>> ini_set("max_execution_time", 18000);
>>
>> Had you considered that this may not be enough time?
>
> I suppose 5 h should be pretty much enough for creating a ZIP file. But
> indeed changing the max_execution_time might fail (e.g. when PHP runs in
> safe mode). However, if the script outputs "Archive created
> successfully.", the execution time can't be the problem.
My mistake -- I thought it specified milliseconds, not seconds. I stand corrected.
[toc] | [prev] | [next] | [standalone]
| From | salil.ag@gmail.com |
|---|---|
| Date | 2012-08-08 21:37 -0700 |
| Message-ID | <77be2f2e-e465-417b-8c51-da840a125952@googlegroups.com> |
| In reply to | #6736 |
try with max_execution_time with some lower value, 5 Hr is too much.
On Wednesday, 8 August 2012 12:10:25 UTC+5:30, Supriya wrote:
> Hi All
>
> i m trying to create a Zip file of 1 folder which contains 2 folders and 33 files but the resulted zip file only contains 21 file and 1 folder.And when i open the files of zip folder it says files r corrupted.
>
>
>
> Here is my code:
>
> Plz help me to find out what is wrong there...
>
>
>
> <?php
>
>
>
> include("variable.php");
>
>
>
> ini_set("max_execution_time", 18000);
>
>
>
>
>
> // create object
>
>
>
> $zip = new ZipArchive();
>
>
>
> // open archive
>
>
>
> if ($zip->open($outputfoldername . ".zip", ZIPARCHIVE::CREATE) !== TRUE) {
>
> die ("Could not open archive");
>
> }
>
>
>
> // initialize an iterator
>
> // pass it the directory to be processed
>
>
>
> $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($outputfoldername . "/"));
>
>
>
> // iterate over the directory
>
> // add each file found to the archive
>
>
>
> foreach ($iterator as $key=>$value) {
>
> $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
>
> }
>
>
>
> // close and save archive
>
>
>
> $zip->close();
>
> echo "Archive created successfully.";
>
> ?>
>
>
>
> Thanks
>
> Regards Supriya
[toc] | [prev] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2012-08-09 07:09 +0200 |
| Message-ID | <a8guvuF1f7U1@mid.individual.net> |
| In reply to | #6736 |
Supriya wrote:
> Hi All
> i m trying to create a Zip file of 1 folder which contains 2 folders and 33 files but the resulted zip file only contains 21 file and 1 folder.And when i open the files of zip folder it says files r corrupted.
>
> Here is my code:
> Plz help me to find out what is wrong there...
>
> <?php
>
> include("variable.php");
>
> ini_set("max_execution_time", 18000);
This will not help you, and as Jerry pointed out you may not be allowed to
change the value.
Sure, the issue may be that the execution of the script needs more time, but
you totally have forgot that there is a timeout in your browser, and when your
browser times out, then the script will stop running on the server too and you
end up with an unfinished job.
>
> // create object
>
> $zip = new ZipArchive();
>
> // open archive
>
> if ($zip->open($outputfoldername . ".zip", ZIPARCHIVE::CREATE) !== TRUE) {
> die ("Could not open archive");
> }
>
> // initialize an iterator
> // pass it the directory to be processed
>
> $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($outputfoldername . "/"));
>
> // iterate over the directory
> // add each file found to the archive
>
> foreach ($iterator as $key=>$value) {
> $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
if you make some output here, then you will extend the life for your
connection, unless one iteration takes too long time.
> }
>
> // close and save archive
>
> $zip->close();
> echo "Archive created successfully.";
> ?>
If you can, make a cron job of this instead (not many web hotels does offer
customers to run cron jobs), the job reads from a database table which jobs it
has to do, it takes the oldest one in the list each time it's run (set it to
run every 5 or 10 minutes) and marks it to be worked on, so that no other
instance will try to do the same time if it takes longer than the time you set
between two jobs, and when the process is finished, mark the job as finished
(this gives you the possibility to check for jobs which fails, specially if
you also set the time when the job changed state).
Then in the web ui you just have a way to put jobs into the queue.
You get a lot more stable system this way.
--
//Aho
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-08-12 19:25 +0200 |
| Message-ID | <a8q77rF8jhU1@mid.uni-berlin.de> |
| In reply to | #6736 |
Am 08.08.2012 08:40, schrieb Supriya: > Hi All > i m trying to create a Zip file of 1 folder which contains 2 folders and 33 files but the resulted zip file only contains 21 file and 1 folder.And when i open the files of zip folder it says files r corrupted. > > Here is my code: > Plz help me to find out what is wrong there... > Is the problem solved? It could be an access restriction problem, be aware that your script runs with the web server account. /Str.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web