如何在浏览器中查看上传的word文件? [英] How to view the uploaded word file in browser?

查看:1077
本文介绍了如何在浏览器中查看上传的word文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

告诉我在浏览器中查看上传的word文件的步骤。我已经在应用程序文件夹中成功上传了word文件,但我无法在浏览器中查看上传的word文件。请给我解决这个问题的方法。我附上下面的代码供你参考。



(注意:在naukri网站上,如果我上传word文件就像简历一样,它会在浏览器中显示,就像我需要的那样]



Default.aspx:

*******************

<asp:Label ID="Label1" runat="server" Text="Please select the file to upload"></asp:Label>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Upload" onclick="Button1_Click" />





Default.aspx.cs:

******************



Default.aspx.cs:
******************

protected void Button1_Click(object sender, EventArgs e)
{
Response.ContentType = "Application/msword";
//Get the physical path to the file.
string FilePath = MapPath("BuildingDataAccessComponent.doc");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
}

推荐答案

尝试将此作为提示添加到浏览器中以显示它:

Try to add this as a hint to the browser for showing it:
Response.AddHeader("content-disposition", "inline;filename=BuildingDataAccessComponent.doc");





祝你好运!



Good luck!


这篇关于如何在浏览器中查看上传的word文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆