jQuery.ajaxFileUpload 上传图片文件

版权声明:本文为博主原创文章,转载请注明出处 http://blog.csdn.net/wxx_csdn https://blog.csdn.net/wxx_csdn/article/details/86621455
<td style="text-align:center;width:200px">
    <img src="images/title1.jpg" id="imsSpeIllnessEditForm_img" style="width:172px;height:98px">
     <div>
        <input type="hidden" id="imsSpeIllnessEditForm_img_url" name="image">
        <input type="file" id="coreSpeIllnessEditForm_img_upload" onchange="imgSpeHospitalUploadReg();" name="imgUpload" style="width:180px;"/>
     </div>
</td>
function imgSpeHospitalUploadReg(){
    var isOk = detection('coreSpeIllnessEditForm_img_upload');
    if(isOk){
        jQuery.ajaxFileUpload({
            url:"url",
            secureuri:false,
            async:false,
            fileElementId:'coreSpeIllnessEditForm_img_upload',
            dataType: 'json',
            success:function(res){
                $("#imsSpeIllnessEditForm_img").attr("src",_basePath+"/"+res.result.imgUpload);
                $("#imsSpeIllnessEditForm_img_url").val(_basePath+"/"+res.result.imgUpload);
            }
        });
    }else{
        $.messager.alert('提示', '请选择图片格式的文件!', 'warning');
        file.after(file.clone().val(""));
        file.remove();
    }
}

猜你喜欢

转载自blog.csdn.net/wxx_csdn/article/details/86621455