Skip to content
Advertisement

Add img from FileReader to latest class | FileReader gets executed after loop

I’m rebuilding a multiple image upload function, but I came across the problem that fileReader() is executed after the whole loop.

Inside the loop I’m cloning foreach dragged image a container expect first one. This container has the class and id “clonemulti”. Inside this container is the “file-return” container which gets cloned too.

For example I’m dragging into the file input field 3 images. The loop runs through, the ParseFile() function is appending to each “file-return” step by step the values for name and size each image (1,2,3), but the setupReader() function appends all images just to the last (3) container.

JavaScript

How can I handle the setupReader() function get executed and appending images to the last “file-return” “imagesrc” class like the ParseFile() function does?

This is a Fiddle of an example: https://jsfiddle.net/3xtg6hew/1/

Advertisement

Answer

I solved the problem by myself, with making an own loop where i looping each class and adding the image there:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement