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
1 Answer
Reset to default 16Listen on fileupload.on('change', function(){})
to get what and when was chosen in file selector.