0

I am trying to build a custom drag drop and file upload. My div container is empty. Upon drop file i am '' an '' type file into the container and want to trigger its file attachment functionality. my code is not working properly . kindly advice or guide. your favour will be appreciated.

following is my code

<div class="drag" ondrop="drop(event)" ondragover="allowDrop(event)">

function allowDrop(event) {
        event.preventDefault();
    }
    function addinputfile(){
        $('.drag').append('<div class="upload"><input type="file" name="ufile[]" id="ufile" multiple></div>');
    }

    function drop(event) {
        event.preventDefault();
        console.log('something dropped here!');
        addinputfile();
        $('#input#ufile').trigger("click");
    }

code is simply adding '' file type and hitting it to use for file upload.

0

1 Answer 1

1

Actually, some browsers won't allow event trigger on the input: file, Click event will work only, when it comes directly from the user.

But alternative is there to do this, refer it here Jquery trigger file input

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.