csdn史上未解决的DSOframer问题

四更山吐月 2011-12-22 05:08:26
关于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();
遗憾的是,这样种方法,都不成功,上传的文件是空文件。
大多数网友都是不满意结贴。
...全文
258 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
webbwebwew 2014-05-28
  • 打赏
  • 举报
回复
document.all.FramerControl1.HttpInit(); document.all.FramerControl1.HttpAddPostCurrFile("FileData", ""); returnValue = document.all.FramerControl1.HttpPost(Url); 直接不走后台代码是怎么回事
fierys 2014-02-12
  • 打赏
  • 举报
回复
http://hi.baidu.com/2597788/item/56d7ede511bb24a3c00d75f5
fishnobone 2013-08-06
  • 打赏
  • 举报
回复
function save(){
         //document.all.oframe.save("c:/1.doc",true);  保存到本地能成功
         document.all.oframe.HttpInit();          //我用IE调试js,在这里报对象不支持此属性或方法错误
         document.all.oframe.HttpAddPostCurrFile("file", "");
         document.all.oframe.HttpPost("<%=basePath%>/save/saveFile.action");
    }
我是jsp调用的。我是js直接报错了,楼主有这个问题的解决经验不
lghjbxc 2013-07-02
  • 打赏
  • 举报
回复
我也觉得奇怪。post的时候java的,报的是没有multipart/form-data。没有这个是根本没有上传图片的。
wrqlgd 2012-03-02
  • 打赏
  • 举报
回复
我也这个问题,郁闷死我了!!!!
四更山吐月 2011-12-23
  • 打赏
  • 举报
回复
自己顶。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧