我用的是dsoframer.ocx 在线打开doc和保存5M以下的doc都没问题,一但内容多了,文件内容大于5M后怎么保存不了,而且很慢,不知道用什么方法可以解决,谢谢各位大哥。
editdoc.aspx代码如下:
function SaveToWeb(){
document.all.FramerControl1.HttpInit();
document.all.FramerControl1.HttpAddPostString("RecordID","20060102200");
document.all.FramerControl1.HttpAddPostString("UserID","aaa");
document.all.FramerControl1.HttpAddPostCurrFile("FileData", "<%=FileName %>");
document.all.FramerControl1.HttpPost("http://"+window.location.host+"/Read_doc/SaveDoc.aspx?FilePath=<%=FileName %>");
alert("对文件的修改已经保存成功!");
window.location.href ="http://127.0.0.1/sys/read.aspx" ;
}
savedoc.aspx代码如下:
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;
using System.Net;
public partial class DsoFramer_SaveDoc : System.Web.UI.Page
{
readonly int enterCount = 12;
string[] requestValues = new string[3];
protected void Page_Load(object sender, EventArgs e)
{
string newFile = Server.MapPath(".") + "\\" + Request.QueryString["FilePath"] + "";
FileStream newDoc = new FileStream(newFile, FileMode.Create, FileAccess.Write);
BinaryReader br = new BinaryReader(Request.InputStream);
BinaryWriter bw = new BinaryWriter(newDoc);
br.BaseStream.Seek(0, SeekOrigin.Begin);
bw.BaseStream.Seek(0, SeekOrigin.End);
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.UTF32Encoding.Default.GetString(br.ReadBytes(streamHeadLen - 1));
while (br.BaseStream.Position < br.BaseStream.Length - 38)
{
bw.Write(br.ReadByte());
}
br.Close();
bw.Flush();
bw.Close();
string[] requestStrings = { "RecordID", "UserID" };
for (int i = 0; i < requestStrings.Length; i++)
{
string str = "Content-Disposition: form-data; name=\"" + requestStrings[i] + "\"\r\n\r\n";
int 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;
}
}
}
}
editdoc.aspx代码如下:
function SaveToWeb(){
document.all.FramerControl1.HttpInit();
document.all.FramerControl1.HttpAddPostString("RecordID","20060102200");
document.all.FramerControl1.HttpAddPostString("UserID","aaa");
document.all.FramerControl1.HttpAddPostCurrFile("FileData", "<%=FileName %>");
document.all.FramerControl1.HttpPost("http://"+window.location.host+"/Read_doc/SaveDoc.aspx?FilePath=<%=FileName %>");
alert("对文件的修改已经保存成功!");
window.location.href ="http://127.0.0.1/sys/read.aspx" ;
}
savedoc.aspx代码如下:
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;
using System.Net;
public partial class DsoFramer_SaveDoc : System.Web.UI.Page
{
readonly int enterCount = 12;
string[] requestValues = new string[3];
protected void Page_Load(object sender, EventArgs e)
{
string newFile = Server.MapPath(".") + "\\" + Request.QueryString["FilePath"] + "";
FileStream newDoc = new FileStream(newFile, FileMode.Create, FileAccess.Write);
BinaryReader br = new BinaryReader(Request.InputStream);
BinaryWriter bw = new BinaryWriter(newDoc);
br.BaseStream.Seek(0, SeekOrigin.Begin);
bw.BaseStream.Seek(0, SeekOrigin.End);
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.UTF32Encoding.Default.GetString(br.ReadBytes(streamHeadLen - 1));
while (br.BaseStream.Position < br.BaseStream.Length - 38)
{
bw.Write(br.ReadByte());
}
br.Close();
bw.Flush();
bw.Close();
string[] requestStrings = { "RecordID", "UserID" };
for (int i = 0; i < requestStrings.Length; i++)
{
string str = "Content-Disposition: form-data; name=\"" + requestStrings[i] + "\"\r\n\r\n";
int 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;
}
}
}
}
解决方案 »
- 怎样让页面上某个Table以外的颜色改变?
- 无法识别的配置节
- EXT封装的.NET控件,加载慢
- Flash + XML + ASP.NET 电子地图
- JMAIL发送邮件时,发送到公司的邮件服务器成功,发送到别的邮件服务器就不成功,怎么回事呢。
- 都来看下,帮帮我~~~~~~~~~~~~~~
- 关于引用自定义控件的问题。
- HttpModule和HttpHandler的请求验证
- 页面访问加载速度慢
- 已有打开的与此连接相关联的 DataReader,必须首先将它关闭,怎么办?
- asp.net连接远程oracle 11g数据库 报错System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本
- 后台不识别生成write出来的fileupload控件【求解】
1、先在服务里关闭 iis admin service 服务。
2、找到 windows\system32\inetsrv\ 下的 metabase.xml 文件。
3、用纯文本方式打开,找到 AspBufferingLimit 把它修改为需要的值(可修改为20M即:20480000)。
4、存盘,然后重启 iis admin service 服务。