I want to move the selected image to the 1st place in the array by clicking
$(document).on('click', '.newProductPic', function () {
$(".newProductPic").removeClass("selectImage");
$(this).addClass("selectImage");
var image = $(".selectImage")[0];
var fReader = new FileReader();
fReader.onloadend = (function (f) {
return function (e) {
var base64ImageString = this.result;
var imageName = f.name;
imagesListContent.push({ base64ImageString, imageName });
addThumbMainImage(base64ImageString, f.name);
currentMainImage = 'newProductPic' + i + '';
};
})(image);
fReader.readAsDataURL(image);
var temp = $(".newProductPic")[0];
imagesListContent[0] = imagesListContent[selectMainImageId];
imagesListContent[selectMainImageId] = temp;
});
I'm getting a mistake: Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'. What am I doing wrong and what are the solutions to this problem?