Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Upload Zip and Extract?


Go to End


4 Posts   2341 Views

Avatar
James K

Community Member, 2 Posts

8 April 2009 at 4:22am

Edited: 08/04/2009 6:18am

Hey everyone.

I was just wondering if anyone had any input on this. I am building a content management site, and for one of the accounts, they send me all of their documentation in the form of a zipped website. Is there a way I can upload the zipped file through DataObjectManager, then have it extract into the database, allowing a link on the account page to go to their index.htm file?

any help would be appreciated.

Thanks.

James

Update:

Found this script to unzip files. I am just not sure how to implement it in the process.

<?php
$zip = zip_open("zip.zip");
if ($zip) {
while ($zip_entry = zip_read($zip)) {
$fp = fopen("zip/".zip_entry_name($zip_entry), "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp,"$buf");
zip_entry_close($zip_entry);
fclose($fp);
}
}
zip_close($zip);
}
?>

Avatar
James K

Community Member, 2 Posts

14 April 2009 at 3:19am

Any ideas?

Avatar
robinp

Community Member, 33 Posts

5 May 2009 at 10:00am

Hi James,

Did you get anywhere with this ? I have exactly the same need.

I'm actually thinking the easier way to do this you some sort php based file browser, instead of getting silverstrip to do it.

Cheers

Robin

Avatar
BenWu

Community Member, 97 Posts

15 May 2012 at 9:16pm

Here is what I do:

Class MyFile extends File {

public function onAfterWrite(){
//do your expand
}

public function onBeforeDelete(){
//remove your zip folder
}
}

class Project extends DataObject {

static $has_one = array('myFile' =>'MyFile');

}

//you can then use DataObjectManager or ModelAdmin to manage project class
works well for me