0

My problem
When saving two or more matrix blocks via a front end form, the Base64-encoded data does not upload an asset for each blocks. The first block gets the last blocks image data, while the rest of the blocks is left empty.

I've doublechecked the payload from the POST request and it seems to checkout.
The image-files vary from 50-100kb each, so I don't think it's a filesize issue either.

Twig code

<form accept-charset="UTF-8" method="post" enctype="multipart/form-data">
    {{ csrfInput() }}
    {{ actionInput('entries/save-entry') }}
    {{ hiddenInput('siteId', currentSite.id) }}
    {{ hiddenInput('entryId', entry.id) }}
    {{ hiddenInput('fields[photomatrix]', '') }}

    {{ hiddenInput('fields[photomatrix][sortOrder][]', 'new1') }}
    {{ hiddenInput('fields[photomatrix][blocks][new1][type]', 'photoblock') }}
    {{ hiddenInput('fields[photomatrix][blocks][new1][enabled]', '1') }}
    {{ hiddenInput('fields[photomatrix][blocks][new1][fields][text]', 'imageName') }}
    {{ hiddenInput('fields[photomatrix][blocks][new1][fields][photo][filename][]', 'imageName.jpg') }}
    {{ hiddenInput('fields[photomatrix][blocks][new1][fields][photo][data][]', '...imageData') }}

    {{ hiddenInput('fields[photomatrix][sortOrder][]', 'new2') }}
    {{ hiddenInput('fields[photomatrix][blocks][new2][type]', 'photoblock') }}
    {{ hiddenInput('fields[photomatrix][blocks][new2][enabled]', '1') }}
    {{ hiddenInput('fields[photomatrix][blocks][new2][fields][text]', 'imageName2') }}
    {{ hiddenInput('fields[photomatrix][blocks][new2][fields][photo][filename][]', 'imageName2.jpg') }}
    {{ hiddenInput('fields[photomatrix][blocks][new2][fields][photo][data][]', '...imageData2') }}
</form>

Setup:

  • Craft Pro 3.6.17
  • PHP 7.4.19
  • MySQL 5.5.5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.