View Full Version : Ajax for file upload

25 Oct 2013, 2:11 AM
Is it possible to use ajax for file upload?

25 Oct 2013, 3:08 AM
Have a look at this example:


T (http://dev.sencha.com/deploy/ext-4.0.0/examples/form/file-upload.html)hanks

25 Oct 2013, 3:22 AM
this example gives solution with form.submit.

how to take filefield in ajax and use that in struts action

25 Oct 2013, 3:29 AM
If you look at the button handler code you will see that it still submits it via ajax (url specified) :) so you can still have your various success, failure, etc functions

handler: function () {
var form = this.up('form').getForm();
if (form.isValid()) {
url: 'file-upload.php',
waitMsg: 'Uploading your photo...',
success: function (fp, o) {
msg('Success', 'Processed file "' + o.result.file +
'" on the server');

25 Oct 2013, 3:50 AM
that code refers for onclick of button it will submit the whole page. url specifed is for form submit url. Its not the ajax request.

Also my specific doubt is, while form submission i can take the form values.

private File attchfile.

for (File file: getFilesToUpload()) {
FileInputStream fstream = new FileInputStream(file);
Blob blb = Hibernate.createBlob(fstream);

How to send in ajax and use in action? please help