i want to upload an image file along with some data through a struts form, process data , and store that image in DB
i have created a form for it , defined action for uploading file in struts.xml file , but when the control comes in java method ,getting null in the File type variable, please help on it.
code in struts.xml :
<action name="uploadFile" class="org.ui.LogActivityAction"
method="uploadFile">
<interceptor-ref name="fileUpload">
<param name="fileUpload.maximumSize">10485760</param>
<param name="fileUpload.allowedTypes">text/plain,image/jpg</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"/>
<result name="success">/user/activity/upload-card.jsp</result>
<result name="error">/user/activity/upload-card.jsp</result>
</action>
ajax used for sending data to action :
function saveSalesUserActivity(card) {
var isValidForm = jQuery('#dailyActivity').valid();
isValidForm = jQuery('#dailyActivity').valid();
if (!isValidForm) {
return;
}
if (isValidForm) {
jQuery.blockUI({
message: "<strong>" + messages("mis.common.wait") + "</strong>"
});
jQuery.ajax({
type: "POST",
url: "/sales/user/logactivity/saveactivity.action?businessCard=" + card,
data: jQuery('#dailyActivity').serialize(),
success: function(response) {
jQuery("#miscontent").html(response);
},
error: function(response) {
jQuery("#miscontent").html(response);
}
});
jQuery.unblockUI();
}
jQuery.unblockUI();
}
through this when reaching in java method,I am not getting the value of File type variable( used 'businessCard' here).. anyone help..