I'm quite new to the cms and would like to know how to programmatically add a zip folder to an asset field in craft cms using a plugin. So like listening to ENTRY_AFTER_EVENT and processing a zip folder and afterwards do something like $event->sender->assetField = zippedFolder

Any assistance is highly appreciated.


  • Zipped folder? Do you mean folder with zip files or what? Do you need to reattach (change) an asset for certain fields?
    – RomanAvr
    Commented Nov 22, 2022 at 20:48
  • While I agree the question could be more precise, you could consider to build on top of an existing plugin like plugins.craftcms.com/compress?craft4. Commented Nov 22, 2022 at 22:01
  • @RomanAvr I meant a compressed folder with some files in it.
    – Iron Brew
    Commented Nov 23, 2022 at 5:17
  • @IronBrew It's a bit difficult to understand what you're asking. Please clarify further what you're trying to do, in as much detail as possible :) Commented Nov 24, 2022 at 13:08

1 Answer 1


Thanks for assistance. I was able to solve the problem by creating an asset, got the asset id and added the asset field to the id: $event->sender->assetField = [newassetid];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.