Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-28T10:15:35.863Z
Answers.LastActivityDate: 2022-11-28T10:15:35.863Z
Answers.UserDisplayName: Iron Brew
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-22T20:48:16.290Z
Comments.Text: Zipped folder? Do you mean folder with zip files or what? Do you need to reattach (change) an asset for certain fields?
Comments.UserDisplayName: RomanAvr
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-22T22:01:13.487Z
Comments.Text: 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.
Comments.UserDisplayName: Max Strebel
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-23T05:17:19.377Z
Comments.Text: @RomanAvr I meant a compressed folder with some files in it.
Comments.UserDisplayName: Iron Brew
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-24T13:08:07.443Z
Comments.Text: @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 :)
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Tags: <craft3><craft4>
Title: How can I add a zip folder to an asset field in craft cms
ThreadText: # 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**: @username_1 I meant a compressed folder with some files in it.  
  > **username_3**: @username_0 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];
  
  
  ---
  
  