Skip to content

Instantly share code, notes, and snippets.

@PizzaLiu
Created May 31, 2013 07:25
Show Gist options
  • Save PizzaLiu/5683397 to your computer and use it in GitHub Desktop.
Save PizzaLiu/5683397 to your computer and use it in GitHub Desktop.
AjaxFileUploader 2.1
<script type="text/javascript" src="./static/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="./static/js/ajaxfileupload.js"></script>
<input name="pic" id="pic" type="file" />
function ajaxFileUpload(){
jq('input[name="pic"]')
.ajaxStart(function(){
jq('span.pic-up-notice').html('<img src="./static/image/common/loading.gif" />图片上传ing...');
})
.ajaxComplete(function(){
jq('span.pic-up-notice').html('图片上传完成!<a class="reedit-pic" href="#">修改图片</a>');
});
jq.ajaxFileUpload
(
{
url:'./home.php?mod=spacecp&ac=plugin&id=tv_prom:tv_prom_admin&act=pic_admin&upfile=pic',
secureuri:false,
fileElementId:'pic',
dataType: 'json',
data:{pizza:'liu'},
success: function (data, status){
if(typeof(data.error) != 'undefined'){
if(data.error != ''){
alert(data.error);
}else{
//alert(data.msg);
jq('.show_pic').css('background-image','url('+data.msg+')');
jq('input[name="picx"]').val(data.msg);
}
}
},
error: function (data, status, e){
alert(e);
}
}
)
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment