-2

I'm trying to read content of zip files from MySQL table, the files store as blob in the table. For example, the table have 3 columns id(integer), filename(varchar), file(longblob), there has a row (1, example, BLOB), the 'BLOB' actually is a zip file, how to read this file and the files list in the zip by PHP?

user2241859
  • 165
  • 2
  • 3
  • 13
  • 1
    *I need a system that works just like facebook where people can befriend eachother, post pictures and post comments on eachothers walls along with private messaging. How do I do this? Please give me code.* Do you see the point? You're expecting us to do everything for you, and you don't show us that you've even done a slight effort. Have you tried googling "*php zip*"? – h2ooooooo Oct 17 '13 at 14:00
  • 2
    Extract the row from the database then use [ZipArchive](http://php.net/manual/en/class.ziparchive.php) class? – naththedeveloper Oct 17 '13 at 14:00
  • @FDL The question is legitimate. Its not simple to init a ZipArchive from a zip that exists only as a string in memory. ZipArchive was made to read .zip files only, and it requires sort of a hack to workaround this. – Havenard Oct 17 '13 at 14:07
  • Duplicate of: http://stackoverflow.com/questions/15140063/extract-a-file-from-a-zip-string – Havenard Oct 17 '13 at 14:10
  • @Havenard I never said the question wasn't legitimate, but you tell me what research of effort OP has put into that question. Creating a temporary file from the BLOB will allow use of `ZipArchive`, but OP needs to learn to use the search function. – naththedeveloper Oct 17 '13 at 14:11
  • 1
    Difficult even to identify what question is being asked because OP hasn't broken it down in any way.... are they having trouble even retrieving the MySQL record to extract the zip file itself, or is it opening the zip file once it's been retrieved that is the problem? – Mark Baker Oct 17 '13 at 14:13

1 Answers1

1

Googling 'php zip' gives this as the first result:

You're probably after ZipArchive::open. You may need to temporarily write the zip to a file to be able to read it. For that, try this.

1owk3y
  • 1,115
  • 1
  • 15
  • 30
  • Good answer, but try not to be so snarky. – tadman Oct 17 '13 at 14:33
  • Apologies. I'm not high enough rep to moderate threads so I attempted to inform the OP as best I could (albeit very aggressively). I'll avoid that in future. – 1owk3y Oct 17 '13 at 14:54