日期:2014-05-17 浏览次数:20885 次
$('#diaryuploadid').change(function(){
$.ajaxFileUpload
({
url: myurl,
fileElementId:"diaryuploadid",
dataType: 'json',
secureuri:false,
success: function (data, status)
{
// ...
},
error: function (data, status, e)
{
alert("上传图片失败!");
}
});
});
createUploadForm: function(id, fileElementId)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = $('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
var oldElement = $('#' + fileElementId);
var newElement = $(oldElement).clone();
$(oldElement).attr('id', fileId);
$(oldElement).before(newElement);
$(oldElement).appendTo(form);
//set attributes
$(form).css('position', 'absolute');
$(form).css('top', '-1200px');
$(form).css('left', '-1200px');
$(form).appendTo('body');
return form;
},
var oldElement = $('#' + fileElementId);
var newElement = $(oldElement).clone();
$(newElement).attr('id', fileId);
$(newElement).appendTo(form);