Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using callback to create multiple file preview #24

Open
koffisani opened this issue May 30, 2019 · 0 comments
Open

Using callback to create multiple file preview #24

koffisani opened this issue May 30, 2019 · 0 comments

Comments

@koffisani
Copy link

koffisani commented May 30, 2019

I'm using the callback functionality to create another field. But can't make it work properly.
After choosing one file, an input field is added dynamically to let user add another file.
My code is as below :

var i=0;
$.uploadPreview({
            input_field: "#image-upload_" + i, // Default: .image-upload
            preview_box: "#image-preview_" + i, // Default: .image-preview
            label_field: "#image-label_" + i, // Default: .image-label
            label_default: "Choisir une image", // Default: Choose File
            label_selected: "Changer d'image", // Default: Change File
            no_label: false ,                // Default: false
            success_callback: function () {
                console.log(i);
                $(img_wrapper).append(
                    '<div class="col-lg-3 col-md-4">' +
                        '<div class="image-preview" id="image-preview__' + i + '">' +
                            '<label for="image-upload_<?= $i + 1 ?>" id="image-label_' + i + '">Choisir une image</label>' +
                            '<input name="files[' + i + ']" required="" id="image-upload_' + i + '" class="image-upload col-lg-12 col-md-12" type="file" style="height: 100%;">' +
                        '</div>' +
                    '</div>'
                );
                i++;
            }
        });

I thought this should work, but unfortunaltely, no. A need someone's touch to know how to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant