最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

what listeners are called when a file is selected from a file chooser in javascript - Stack Overflow

programmeradmin2浏览0评论

I'm working on creating an upload button for my website but I'm unable to trigger events based on when the file is selected for the upload. I was under the impression that the .submit function did this but I'm unable to get any results from this. HTML

    <input type="button" id="uploadbutton" value="Upload File" />
    <form action="includes/uploader.php" method="POST" id="fileupload_form">
        <input id="fileupload" type="file" name="files[]" multiple style="display:none;">
        <input id="server" type="hidden" name="server" value="upload">
        <input type="hidden" id="storeA" value="statement_upload" name="storeA">
    </form>

Javascript/jQuery

var fileupload = $("#fileupload");

$("#uploadbutton").click( function(){
    fileupload.click();
});

$("#fileupload_form").submit( function(e){}

This javascript function will not run when trying to select the file and no errors are given. Any and all help is appreciated!

I'm working on creating an upload button for my website but I'm unable to trigger events based on when the file is selected for the upload. I was under the impression that the .submit function did this but I'm unable to get any results from this. HTML

    <input type="button" id="uploadbutton" value="Upload File" />
    <form action="includes/uploader.php" method="POST" id="fileupload_form">
        <input id="fileupload" type="file" name="files[]" multiple style="display:none;">
        <input id="server" type="hidden" name="server" value="upload">
        <input type="hidden" id="storeA" value="statement_upload" name="storeA">
    </form>

Javascript/jQuery

var fileupload = $("#fileupload");

$("#uploadbutton").click( function(){
    fileupload.click();
});

$("#fileupload_form").submit( function(e){}

This javascript function will not run when trying to select the file and no errors are given. Any and all help is appreciated!

Share Improve this question asked May 22, 2013 at 20:36 DitRDitR 1331 gold badge1 silver badge4 bronze badges 1
  • possible duplicate of HTML File input JS events – Barmar Commented May 22, 2013 at 20:54
Add a comment  | 

1 Answer 1

Reset to default 16

Listen on fileupload.on('change', function(){}) to get what and when was chosen in file selector.

发布评论

评论列表(0)

  1. 暂无评论