Hi,
I’ve got my fields displayed {field:gallery_image1} {field:gallery_image2} {field:gallery_image3} wihtin channel form tags working correctly. I’ve implemented a custom drag drop image uploader feature that i wrote myself as below:
<pre><code>$(‘.drag-drop-upload’).on(‘drop’, function(e){ e.preventDefault(); $(this).css(‘border’, ‘2px dashed #000’); var files = e.originalEvent.dataTransfer.files; insertImagesIntoInputs(files); }).on(‘dragover’, function(e){ e.preventDefault(); e.stopPropagation();
}).on('dragenter', function(e){
e.preventDefault();
e.stopPropagation();
$(this).css('border', '2px dashed #000');
});
function insertImagesIntoInputs(images){
var numberOfImages = images.length;
for (i=0; i < numberOfImages; i++) {
var formData = new FormData();
formData.append('giri', images[i]);
}
for(i=0; i < numberOfImages; i++) {
var target = 'input[name=gallery_image' + i+1 +']';
console.log(target, images[i].name);
$(target).val(images[i].name);
}
console.log(formData, form);
}[/code]
Now i;m looking into pushing the images into the {field:…} values to complete the upload when submitting the form. Any help appreciated.
Thanks
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.