<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"/>
<meta content="C#" name="CODE_LANGUAGE"/>
<meta content="JavaScript" name="vs_defaultClientScript"/>
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"/>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
</head>
<body>
<form id="Form2" method="post" runat="server" encType="multipart/form-data">
<input type=text name="RecordID" value=<%=Request.QueryString["RecordID"]%>>
</form>
</body>
2.后台相关的处理代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
namespace OnlineWord
{
public partial class SaveDoc : System.Web.UI.Page
{
readonly int enterCount = 12;
string[] requestValues = new string[3];
protected void Page_Load(object sender, System.EventArgs e)
{
string newFile = Server.MapPath("~/1236.doc");
BinaryReader br = new BinaryReader(Request.InputStream);
br.BaseStream.Seek(0, SeekOrigin.Begin);
int enterNo = 0;
int streamHeadLen = 0;
while (br.BaseStream.Position < br.BaseStream.Length)
{
streamHeadLen++;
char c = (char)br.ReadByte();
if (enterNo < enterCount)
{
if (c == '\n')
{
enterNo++;
}
}
else
{
break;
}
}
br.BaseStream.Seek(0, SeekOrigin.Begin);
string strTemp = System.Text.UTF8Encoding.Default.GetString(br.ReadBytes(streamHeadLen - 1));
string str = "";
int index = 0;
string[] requestStrings = { "RecordID", "UserID" };
for (int i = 0; i < requestStrings.Length; i++)
{
str = "Content-Disposition: form-data; name=\"" + requestStrings[i] + "\"\r\n\r\n";
index = strTemp.IndexOf(str) + str.Length;
if (index != str.Length - 1)
{
for (int j = index; j < strTemp.Length; j++)
{
if (strTemp[j] != '\r')
this.requestValues[i] += strTemp[j];
else
break;
}
}
}
str = "; filename=\"";
index = strTemp.IndexOf(str) + str.Length;
if (index != str.Length - 1)
{
for (int j = index; j < strTemp.Length; j++)
{
if (strTemp[j] != '\r')
this.requestValues[2] += strTemp[j];
else
break;
}
}
FileStream newDoc = new FileStream(newFile, FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(newDoc);
bw.BaseStream.Seek(0, SeekOrigin.End);
while (br.BaseStream.Position < br.BaseStream.Length - 38)
{
bw.Write(br.ReadByte());
}
br.Close();
bw.Flush();
bw.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
}
#endregion
}
}