[size=medium][color=green][b]<input type="file" name="creativeResourceImage" id="creativeImage">
<input type="button" id="j-upload" value="上传"/>
<input type="hidden" name="creativeResourceUrl" id="creativeResourceUrl"/>
页面ajax
$.ajaxFileUpload({
url: '${rc.contextPath}/fileUpload/creativeInfoUpload',
secureuri: false,
fileElementId: 'creativeImage',
dataType: 'json',
success: function (json, status) {
if (json.result == 'true') {
var filePath = json.filePath;
var fullPath = "${staticDomainImg}"+filePath;
$("#creativeResourceUrl").val(fullPath);
alert(fullPath);
} else {
alert("上传的图片不能大于500KB");
}
},
error: function (data, status, e)//服务器响应失败处理函数
{
alert(e);
}
});
controller:
UploadFile uploadFile = FileUpDownUtils.getUploadFile(request, "creativeResourceImage");
传给前端的文件参数名,也应该是type=file的name,请注意
[/b][/color][/size]
<input type="button" id="j-upload" value="上传"/>
<input type="hidden" name="creativeResourceUrl" id="creativeResourceUrl"/>
页面ajax
$.ajaxFileUpload({
url: '${rc.contextPath}/fileUpload/creativeInfoUpload',
secureuri: false,
fileElementId: 'creativeImage',
dataType: 'json',
success: function (json, status) {
if (json.result == 'true') {
var filePath = json.filePath;
var fullPath = "${staticDomainImg}"+filePath;
$("#creativeResourceUrl").val(fullPath);
alert(fullPath);
} else {
alert("上传的图片不能大于500KB");
}
},
error: function (data, status, e)//服务器响应失败处理函数
{
alert(e);
}
});
controller:
UploadFile uploadFile = FileUpDownUtils.getUploadFile(request, "creativeResourceImage");
传给前端的文件参数名,也应该是type=file的name,请注意
[/b][/color][/size]