<script>
	$(document).ready(function () {
		$("#btnUploadLitpic").click(function(){
			$("#iptLitpic").click();
		})
		$("#iptLitpic").change(function (val) {
			var formData = new FormData();
			var fileData = $('#iptLitpic')[0].files[0];
			formData.append('file', fileData);
			$.ajax({
				url: '<?php echo $cfg_cmsurl;?>/user/api.php?action=upload&type=litpic',
				type: 'POST',
				data: formData,
				processData: false,
				contentType: false,
				success: function (result) {
					if (result.code === 0) {
						$("#imgLitpic").attr('src', result.data);
						$("#litpic").val(result.data);
					} else {
						ShowMsg(result.msg);
					}
				},
				error: function (xhr, status, error) {
					ShowMsg("文件上传失败");//处理上传失败后的回调
				}
			});
		});
	});
</script>