Answers.Body: <p>It seems like this was a bug and was solved in Craft CMS 5.4.7</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-15T10:41:54.777Z
Answers.LastActivityDate: 2024-10-15T10:41:54.777Z
Answers.UserDisplayName: obs
Body: <p>I'm building a front end form to create / edit entries where I also have an asset field. The uploading of files works fine, but when editing an existing entry, I can't remove the current asset (link).</p>
  <p>When I don't pass the IDs of the currently linked assets when resaving the entry, the links should disappear. (As described here: <a href="https://craftcms.com/docs/5.x/reference/field-types/assets.html#development" rel="nofollow noreferrer">https://craftcms.com/docs/5.x/reference/field-types/assets.html#development</a>).</p>
  <p>So when submitting the form, I see the following in the request (excerpt):</p>
  <pre><code>-----------------------------366693930238477068852192657275
  Content-Disposition: form-data; name=&quot;fields[fotos][]&quot;; filename=&quot;&quot;
  Content-Type: application/octet-stream
  
  
  -----------------------------366693930238477068852192657275
  xxx
  </code></pre>
  <p>Since the field with the name is present and has no value, I assume the entry to have an empty field with the name 'fotos' afterwards. But the field still has the asset linked, as before.</p>
  <p>When I have already uploaded files and include them with hidden inputs and also upload a new file (as described in the link above), only the new file is linked afterwards.</p>
  <p>Interestingly, when I remove <code>enctype=&quot;multipart/form-data&quot;</code> from the form tag, an empty file input removes the linked asset. But I can't upload new assets any longer.</p>
  <p>Am I doing something wrong?</p>
  
Tags: <frontend-form><craft5><assets-field>
Title: front end form with empty asset field and enctype="multipart/form-data" doesn't remove existing asset link
ThreadText: # front end form with empty asset field and enctype="multipart/form-data" doesn't remove existing asset link
  
  (Asked by: username_0 on 2024-10-08)
  
  I'm building a front end form to create / edit entries where I also have an asset field. The uploading of files works fine, but when editing an existing entry, I can't remove the current asset (link).
  
  When I don't pass the IDs of the currently linked assets when resaving the entry, the links should disappear. (As described here: <https://craftcms.com/docs/5.x/reference/field-types/assets.html#development>).
  
  So when submitting the form, I see the following in the request (excerpt):
  
  ```
  -----------------------------366693930238477068852192657275
  Content-Disposition: form-data; name="fields[fotos][]"; filename=""
  Content-Type: application/octet-stream
  
  -----------------------------366693930238477068852192657275
  xxx
  
  ```
  
  Since the field with the name is present and has no value, I assume the entry to have an empty field with the name 'fotos' afterwards. But the field still has the asset linked, as before.
  
  When I have already uploaded files and include them with hidden inputs and also upload a new file (as described in the link above), only the new file is linked afterwards.
  
  Interestingly, when I remove `enctype="multipart/form-data"` from the form tag, an empty file input removes the linked asset. But I can't upload new assets any longer.
  
  Am I doing something wrong?
  
  **Tags:** frontend-form, craft5, assets-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-10-15. Score: 1 | Accepted answer
  
  It seems like this was a bug and was solved in Craft CMS 5.4.7
  
  
  ---
  
  