Hi all,
I already have a Webspeed routine that successfully grabs a single image sent from the client - I do a GET-LONG-VALUE into a Longchar, BASE64-DECODE it into a Memptr and COPY-LOB it out to disc. All good.
I'm now hoping to develop something based on a multiple file select/upload capability in JavaScript. I have an input like this:
and JS to copy the files into form data and post them, like this:
The JS is fine - it comes from a website, and is proven - but I don't know how to unpack the array of files in WebSpeed. Would I start with GET-LONG-VALUE again and move it into something like a JsonObject / JsonArray that I could iterate through? Might it be better to split the images out into multiple POSTs in the JS so I don't have to deal with arrays?
TIA
Tarby
I already have a Webspeed routine that successfully grabs a single image sent from the client - I do a GET-LONG-VALUE into a Longchar, BASE64-DECODE it into a Memptr and COPY-LOB it out to disc. All good.
I'm now hoping to develop something based on a multiple file select/upload capability in JavaScript. I have an input like this:
Code:
<input type="file" id="fileInput" accept="image/*" name="files[]" enctype="multipart/form-data" multiple />
and JS to copy the files into form data and post them, like this:
Code:
const fileInput = document.getElementById("fileInput");
const selectedFiles = fileInput.files;
const formData = new FormData();
for (let i = 0; i < selectedFiles.length; i++) {
formData.append("files[]", selectedFiles[i]);
}
const xhr = new XMLHttpRequest();
xhr.open("POST", [myUrl], true);
xhr.send(formData);
The JS is fine - it comes from a website, and is proven - but I don't know how to unpack the array of files in WebSpeed. Would I start with GET-LONG-VALUE again and move it into something like a JsonObject / JsonArray that I could iterate through? Might it be better to split the images out into multiple POSTs in the JS so I don't have to deal with arrays?
TIA
Tarby
Last edited: