0

Goal

I only have baes64/blob data available from a <canvas /> and want to upload the image via from submission in front-end.

Methods I've tried

I've read about Uploading Files from Front-End Entry Forms in doc.

CraftCMS ONLY supports <input type="file">. The file type input does not support accepting re-assign value like other input tags directly.

Max Ma
  • 880
  • 8
  • 13

2 Answers2

1

Assets fields do actually support submitting Base64-encoded data; it just wasn’t documented. Done now though!

Brandon Kelly
  • 1,973
  • 2
  • 20
  • 38
0

The file type input now support reassign value.
Steps:

  1. convert your blob into file obj

  2. Update your Filelist in js.

  3. Updated Filelist replace with your input files.

    let file = new File([blob], fileName);
    let list = new DataTransfer();
    list.items.add(file);
    $(input)[0].files = myFileList;

Here is original thread