Skip to content

Instantly share code, notes, and snippets.

@RimonEkjon
Last active August 29, 2015 14:05
Show Gist options
  • Save RimonEkjon/0a9ac7068a0fac396a90 to your computer and use it in GitHub Desktop.
Save RimonEkjon/0a9ac7068a0fac396a90 to your computer and use it in GitHub Desktop.
Ajax Image upload without refreshing the form
<form action="processupload.php" method="post" enctype="multipart/form-data" id="MyUploadForm">
<input name="ImageFile" id="imageInput" type="file" />
<input type="submit" id="submit-btn" value="Upload" />
<img src="images/ajax-loader.gif" id="loading-img" style="display:none;" alt="Please Wait"/>
</form>
$(document).ready(function() {
var options = {
target: '#output',
beforeSubmit: beforeSubmit,
success: afterSuccess,
resetForm: true
};
$('#MyUploadForm').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment