I am using the AjaxFileUpload script and it works well, however i was trying to get it to require the pressing of a button. Right now it fires directly after you find your image to upload on the file browser. I cannot tell why and I think it is how the plugin is written, but maybe you can take a look at the logic:
This method works: The file is uploaded right after it is submitted.
<form method="post" action="" enctype="multipart/form-data">
<label>File Input: <input type="file" name="file" id="demo1" /></label>
<div id="uploads">
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#demo1").AjaxFileUpload({
});
</script>
This method does not work. Clicking the Submit button will do nothing. However, the second time a file is browsed to (file button is clicked for a second time) it will operate in the same manner as the first method.
<form method="post" action="" enctype="multipart/form-data">
<label>File Input: <input type="file" name="file" id="demo1" /></label>
<div id="uploads">
</div>
</form>
<input class = "Submit" name="Submit" type="button" value="Submit" />
<script type="text/javascript">
$(document).ready(function() {
$(".Submit").click(function(){
$("#demo1").AjaxFileUpload({
});
});
});
</script>
I think there is a fundamental programming issue here I am missing. If you are interested in the (short) code of this plugin here is the link: https://github.com/davgothic/AjaxFileUpload/blob/master/jquery.ajaxfileupload.js