首先建一个asp.net页面,里面包含生成所需的logo上传file控件:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="QrLogCode.aspx.cs" Inherits="AdminTest_QrLogCode" %>
<!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 id="Head1" runat="server">
<title>二维码生成工具(带log)</title>
<script type="text/javascript" src="../Jscript/admin/jquery-1.4.2.js"></script>
<script src="../Jscript/admin/jquery.form.js" type="text/javascript"></script>
<style type="text/css">
.style1
{
width: 100%;
min-width: 800px;
text-align: left;
}
.txt
{
width: 40%;
}
</style>
</head>
<body>
<form id="form1" enctype="multipart/form-data">
<div>
<table class="style1">
<tr>
<td style="text-align: right; width: 20%;">
输入要生成二维码的内容:
</td>
<td>
<input type="text" id="txt_qr" name="txt_qr" value="https://zhengdecai.com/" class="txt" /> <span>请使用生成“<a
href="BarCode.aspx">条形码</a>”</span>
</td>
</tr>
<tr>
<td style="text-align: right;">
二维码图片:
</td>
<td>
<img id="qrimg" alt="二维码图片" src="../images/20130424105224.jpg" />
</td>
</tr>
<tr>
<td style="text-align: right;">
log图片:
</td>
<td>
<input type="file" id="fileLog" name="fileLog" />
</td>
</tr>
<tr>
<td style="text-align: right;">
尺寸大小:
</td>
<td>
<input id="txt_size" name="txt_size" type="text" value="4" class="txt" />
</td>
</tr>
<tr>
<td colspan="4">
<div style="text-align: left; padding-left: 200px; margin-top: 50px;">
<input id="btnSubmit" type="button" value="生成二维码" /></div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<script type="text/javascript">
$(function () {
$("#btnSubmit").click(function () {
/*if ($("[id$='fileLog']").val() == "") {
alert("请选择log图片的文件!");
return false;
}*/
var txt_qr = $("#txt_qr").val();
var txt_size = $("#txt_size").val();
$("[id$='form1']").ajaxSubmit({
url: "../AjaxUrl/Admin/QrLogCode.ashx",
type: "post",
dataType: 'text',
resetForm: "true",
success: function (data) {
var dataObj = data;
if ($(dataObj).text() != "") {
$("#qrimg").attr("src", "../File/" + $(dataObj).text());
}
else {
$("#qrimg").attr("src", "../File/" + dataObj);
}
$("#txt_qr").val(txt_qr);
$("#txt_size").val(txt_size);
},
error: function (request, message, ex) {
alert("错误:" + message);
}
});
});
});
</script>