I'm developing a wordpress page to submit a post and its images attachment. I don't use input type="file" instead use jQuery wordpress media library.
frame.on("select", function () {
var attachments = frame
.state()
.get("selection")
.map(function (attachment) {
attachment.toJSON();
return attachment;
});
for (i = 0; i < attachments.length; ++i) {
//sample function 1: add image preview
imgContainer.after(
'<div class="jrl-image-preview"><img src="' +
attachments[i].attributes.url +
'" ></div>'
);
//sample function 2: add hidden input for each image
imgContainer.after(
'<input id="jrl-image-input' +
attachments[i].id +
'" type="hidden" name="jrl_attachment_id_array[]" value="' +
attachments[i].id +
'">'
);
}
But I don't know how to save the image files into wordpress DB and upload folder. I tried using $_FILES to get uploaded files but its empty array.
Thanks in advance