Wednesday, 14 May 2014

JavaScript/Ajax file upload with Jquery iframe post

Demo code
<script type="text/javascript" src="jQueryAjaxUpload.js"></script>

<form method="post" action="" enctype="multipart/form-data" id="example_form">
<input type="file" name="file"/>
<input type="submit"/>
</form>
<script>

$('#example_form').ajaxUpload({

post :
function (){

alert('posted');
},


complete :
function() {

alert('Upload complete');
}


});
</script> In case of using spring add below bean to spring beans
<bean id="multipartResolver"

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<!-- one of the properties available; the maximum file size in bytes -->

<property name="maxUploadSize" value="1000000"/>
</bean>
 Follow the below link to download jQueryAjaxUpload.js file

http://www.jainaewen.com/files/javascript/jquery/iframe-post-form.html

No comments:

Post a Comment

Run Postman API remote or code or command line

POSTMAN is used to run the APIs generally. What if we want to create a collection in postman and run it from some other code or command l...