On Sun, 2010-10-17 at 17:22 -0700, Justin Martin wrote:
> On 10-10-17 03:55 PM, Dotan Cohen wrote:
> > I need to provide a download of a zip archive containing three files.
> > This is fairly straightforward in PHP so long as one is working with
> > files that already exist. However, I need to customise one of the
> > files (a simple text file) with the user name and other info before
> > zipping. I see no mention of this in the fine manual, and even
> > googling has led me nowhere. Ideas? Am I missing something obvious?
> >
> > Thanks!
> >
> 
> The solution to this seems to be as simple as grabbing the contents of 
> the file using ZipArchive::getFromName (or equivalent), deleting that 
> file in the archive, modifying the contents, then writing the file using 
> ZipArchive::addFromString.
> 
> Were ZipArchive::getStream able to handle write operations, I imagine 
> you could modify it this way, but reading the file in for modification 
> is much less issue-laden.
> 
> I haven't tested it, but you could also simply try using 
> ZipArchive::addFromString without deleting the file first. It may just 
> overwrite the file.
> 
> Thanks,
> Justin Martin
> 

I ran into this issue with something similar, where i wanted to unzip a
file from file_get_contents(), but it required a "real file"... the
solution (copied from this the reply on here)

On Mon, 2010-10-04 at 10:12 -0700, Jim Lucas wrote:
> Might see if this page will glean you any information
> http://us3.php.net/manual/en/wrappers.php.php
>
> I think the php://temp or php://memory will work for you instead of a
> file on the file system. 

maybe this will help you create a "temp file" in memory taht you can add
to the zip file.

Hope that helps :)

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to