如何在struts2中使用Ajax上传图像文件

时间:2014-04-19 14:23:06

标签: java jquery ajax jsp struts2

function myPage() {
        var url1 = "imagefile="+"img/"+ absPath;

        $.ajax({
            type : "POST",
            url : "fileupload.action",
            data :  $('#uploadImagess').attr('mynewfile'),
            success : function(data) {
                alert("success Insert : "+filePath);

            },
            error : function(data) {
                alert("ERROR IN SAVE DATA");
            }

        }); 
}

1 个答案:

答案 0 :(得分:1)

$(document).ready(function(){   
     $('input[type="file"]').ajaxfileupload({
          'action': 'imageupload.action',               
      'onComplete': function(response) {            
            $('#upload').hide();
            alert("File SAVED!!");
          },
          'onStart': function() {
            $('#upload').show(); 
          }
     });
}); 
</script>