csdn史上未解决的DSOframer问题

四更山吐月 四更山吐月 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
关于DSOframer上传文件到服务器的问题,搜索了一天,无果。
该问题不能沉啊。
特贴出来,请高手支招。

word在线编辑页面:js函数
function SaveToWeb(){

document.getElementById("SureOffice").HttpInit();
document.getElementById("SureOffice").HttpAddPostCurrFile("FileData", "");
document.getElementById("SureOffice").HttpPost("./SaveToServer.aspx");

}
大家看到了,其实上传主要的代码都在SaveToServer.aspx文件中,而很多帖子只介绍dsoFramer的接口,并没有真正的上传成功过。
请看网友写的心得:
上传文件例子:
//初始化Http引擎
DsoFramer1.HttpInit();
//增加Post变量
DsoFramer1.HttpAddPostString("RecordID","20060102200");
DsoFramer1.HttpAddPostString("UserID","李局长");以上这两行,就是打酱油的,用李局长吓唬悲催的程序员们。。
//上传打开的文件
DsoFramer1.HttpAddPostCurrFile("FileData", "文档名.doc");
//执行上传动作
DsoFramer1.HttpPost("http://xxxx.com/uploadfile.asp");//到此介绍就介绍了?重点是uploadfile.asp


搜了搜基本有两种方法:
(1) BinaryReader bReader = new BinaryReader(Request.InputStream);
string strTemp = Encoding.GetEncoding("iso-8859-1").GetString(
bReader.ReadBytes((int)bReader.BaseStream.Length), 0, (int)bReader.BaseStream.Length);
string match = "Content-Type: application/msword\r\n\r\n";
int pos = strTemp.IndexOf(match) + match.Length;
bReader.BaseStream.Seek(pos, SeekOrigin.Begin);

string newFile = Server.MapPath(".") + "\\MyFile2.doc";
FileStream newDoc = new FileStream(newFile, FileMode.Create, FileAccess.Write);
BinaryWriter bWriter = new BinaryWriter(newDoc);
bWriter.BaseStream.Seek(0, SeekOrigin.End);


while (bReader.BaseStream.Position < bReader.BaseStream.Length - 38)
bWriter.Write(bReader.ReadByte());

bReader.Close();
bWriter.Flush();
bWriter.Close();

(2) if (Request.Files.Count == 0)
{
Response.Write("No File");
Response.End();
}

if (Request.Files[0].ContentLength == 0)
{
Response.Write("File Error");
Response.End();
}

//定义保存文件的物理路径
string strTmpPath = System.IO.Path.GetDirectoryName(Page.Request.PhysicalPath);

//定义保存文件的服务器路径
string strUpLoadFilePath = strTmpPath;

string fullFileName = strUpLoadFilePath + "aa.doc";

Request.Files[0].SaveAs(fullFileName);
Response.Write("OK");
Response.End();
遗憾的是,这样种方法,都不成功,上传的文件是空文件。
大多数网友都是不满意结贴。
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
四更山吐月
.NET社区 62,272 成员 668,968 内容