比较不错的图片上传插件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>上传</title>
<script typet="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://malsup.github.io/jquery.form.js" type="text/javascript"></script>
<script>

 function changimg(id){
       var img=$(id).val();
       var fileId,imgId,imgDspId,pre,imgval;
       fileId=id.id;
       pre=id.id.split('-')[0];
       imgId=pre+"-Img";
       imgDspId=pre+"-ImgDsp";
       formId=pre+"-Form";
       imgval=imgDspId+"-val";
       if($("#"+formId).length<=0){                 
            $("#"+fileId).wrap("<form id='"+formId+"' action='/recommend/upload ' method='post' enctype='multipart/form-data'></form>");
       }                   
        $("#"+formId+"").ajaxSubmit({
            dataType:  'json',
            async: false,
            beforeSend: function() {
            },
            success: function(result) {
                if(result.result=="10000"){
                  //  $('#erweiSrc').attr('src',result.dataRes.imgurl.imgrs);
                }else{

                   // createDialog(result.msg);
                }
            },
            error:function(xhr){
                //createDialog(result.msg);
            }
        });
    }
    
    //图片上传
    function changimg1(id){
        
       var img=$(id).val();
       var fileId,imgId,imgDspId,pre,imgval;
       fileId=id.id;
       pre=id.id.split('-')[0];
       imgId=pre+"-Img";
       imgDspId=pre+"-ImgDsp";
       formId=pre+"-Form";
       imgval=imgDspId+"-val";
      
       if($("#"+formId).length<=0){                 
            $("#"+fileId).wrap("<form id='"+formId+"' action='./upload.php' method='post' enctype='multipart/form-data'></form>");
       }                   
        $("#"+formId+"").ajaxSubmit({
            dataType:  'json',
            async: false,
            beforeSend: function() {
            },
            success: function(result) {
                if(result.state=="10000")
                {
                    $('.perphoto').attr('src',result.logoUrl);
                }
            },
            error:function(xhr){
                
                
            }
        });
    }

 

 


</script>

</head>
<span class="Fr gray"><img class="perphoto" src="http://head.cnfolimg.com/04/ea/35832/head.35832.96?84327" alt=""></span>
        头像</a>
<input onchange="changimg1(this)" id="photo" class="photo" type="file"  name="file">

 


<body>

 


</body>
</html>

 

转载于:https://my.oschina.net/hongjiang/blog/1505394

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值