PHP Classes

online zip modifier

Recommend this page to a friend!

      Online zip modifier  >  All threads  >  online zip modifier  >  (Un) Subscribe thread alerts  
Subject:online zip modifier
Summary:ZIP-File from mySQL-BLOB-field
Messages:5
Author:Manthey
Date:2009-03-27 07:53:05
Update:2009-03-28 20:18:35
 

  1. online zip modifier   Reply   Report abuse  
Picture of Manthey Manthey - 2009-03-27 07:53:05
How can I transfer the contents of a blob-field from a mySQL-db (assumed this contains a zip-archive) in a ZIP-object without having to save it first in the file system of the server?
Kind regards and many thanks for your work

  2. Re: online zip modifier   Reply   Report abuse  
Picture of M H Rasel M H Rasel - 2009-03-27 22:32:32 - In reply to message 1 from Manthey
Hi,
Thanks for your question. It is not so hard. retrieve the data from the db in a variable say $b_data and then use the following line to put that on zip.

$zipfile1->create_file($b_data, "usetest/usecode.php"); // Add a file into zip the loaded zip

Hope it will help u

Regards
Hasan

  3. Re: online zip modifier   Reply   Report abuse  
Picture of Manthey Manthey - 2009-03-28 15:25:02 - In reply to message 2 from M H Rasel
I think, this is probably a misunderstanding. My question might have been ambiguous - because of my poor English.
The process is as follows: I bundle a varying number of small files in a zip-file that is stored in a BLOB-field. In reverse direction the files in the Zip archive are to be delivered. In order to do that the Blob-Field is read out and a ZIP file is created in the filesystem of the server. Finally this is read from the hard disk and opened to extract and deliver the containing entries.
My hope is to avoid the writing to the filesystem. Instead I would like to read the character string (I receive from the BLOB-field) directly into a ZIP object.
I think your class could be a solution for this task. However, up to now I was not able to figure out how. Can You help me?

  4. Re: online zip modifier   Reply   Report abuse  
Picture of M H Rasel M H Rasel - 2009-03-28 19:35:41 - In reply to message 3 from Manthey
Hi,
I think your solution is in my last post. Well let me make it more clear. So far i understand you want to add some file into a zip archive but the file data will come from a blob field. If yes then first retrieve the data from the blob field and keep it on some variable (i used the variable $b_data at my prev post for this). Then suppose the name of the file in the zip archive is usecode.php and it will be under the folder (in the zip archive) usetest. So to add the file into zip archive u need to use this following line.

$zipfile1->create_file($b_data, "usetest/usecode.php");

here $zipfile1 is the instance of the zipfile class

Hope now it is cleared to you.

Regards

  5. Re: online zip modifier   Reply   Report abuse  
Picture of Manthey Manthey - 2009-03-28 20:18:35 - In reply to message 4 from M H Rasel
Hi, many thanks for your response.

> So far i understand you want to add some file into a zip archive but the
> file data will come from a blob field

I am sorry, but this is not the problem. The zip file comes from the db and the data contained in the zip-file has to be unpacked and be handed on.
At the moment the ZIP file is written to the filesystem and then is loaded anew:

(1) $result = file_put_contents('newzipfile.zip', $datafromdb, LOCK_EX);
(2) $myZip = new ZipArchive;
(3) $myZip->open('newzipfile.zip');

I would like to avoid steps (2) and (3).

Yours sincerely