Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Upload Zip and Extract?

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1405 Views
  • James K
    Avatar
    Community Member
    2 Posts

    Upload Zip and Extract? Link to this post

    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);
    }
    ?>

  • James K
    Avatar
    Community Member
    2 Posts

    Re: Upload Zip and Extract? Link to this post

    Any ideas?

  • robinp
    Avatar
    Community Member
    33 Posts

    Re: Upload Zip and Extract? Link to this post

    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

  • BenWu
    Avatar
    Community Member
    87 Posts

    Re: Upload Zip and Extract? Link to this post

    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

    1405 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.