<p>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-&gt;sender-&gt;assetField = [newassetid];</p>

CC BY-SA 4.0
2022-11-28T10:15:35.863Z
2022-11-28T10:15:35.863Z
Iron Brew
<p>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 <code>$event-&gt;sender-&gt;assetField = zippedFolder</code></p>
<p>Any assistance is highly appreciated.</p>
<p>Thanks!</p>

CC BY-SA 4.0
2022-11-22T20:48:16.290Z
Zipped folder? Do you mean folder with zip files or what? Do you need to reattach (change) an asset for certain fields?
RomanAvr
CC BY-SA 4.0
2022-11-22T22:01:13.487Z
While I agree the question could be more precise, you could consider to build on top of an existing plugin like https://plugins.craftcms.com/compress?craft4.
Max Strebel
CC BY-SA 4.0
2022-11-23T05:17:19.377Z
@RomanAvr I meant a compressed folder with some files in it.
Iron Brew
CC BY-SA 4.0
2022-11-24T13:08:07.443Z
@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 :)
Mats Mikkel Rummelhoff
<craft3><craft4>
How can I add a zip folder to an asset field in craft cms
# How can I add a zip folder to an asset field in craft cms

(Asked by: username_0 on 2022-11-22)

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.

Thanks!

**Tags:** craft3, craft4
> **Comments:**
> **username_1**: Zipped folder? Do you mean folder with zip files or what? Do you need to reattach (change) an asset for certain fields?  
> **username_2**: While I agree the question could be more precise, you could consider to build on top of an existing plugin like https://plugins.craftcms.com/compress?craft4.  
> **username_0**: @RomanAvr I meant a compressed folder with some files in it.  
> **username_3**: @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 :)  

---

## 1 answers

### Answer by username_0 on 2022-11-28. Score: 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];


---

