Click here to Skip to main content
16,004,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi sir,
Tell me the steps to view the uploaded word file in browser. I have successfully uploaded the word file in the application folder, but i cant able
to view the uploaded word file in browser. Kindly give me the solution for this problem. I attached the code below for your reference.

(Note: In naukri website, if i uploaded word file like resume it is displaying in browser, like that i need]

Default.aspx:
*******************
XML
<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:
******************
C#
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();
}
Posted
Updated 24-Apr-13 20:28pm
v2
Comments
StianSandberg 25-Apr-13 2:30am    
What do you mean by "to view the uploaded word file in browser"? Do you mean show a link so that the user can download the .doc(x) file or do you want to show the content of the word-file as html?
Prabu Spark 25-Apr-13 2:37am    
Hi sir,
I have one upload button, if i upload any word file, it has to save in my project location. After finish uploading it has to show the word file in browser. Consider the website like naukri, if i upload my resume in that website, it will show the content in browser know, like that i need.
Prasad Khandekar 25-Apr-13 2:45am    
Try http://groupdocs.com/apps/viewer or http://www.snowbound.com/products/document-viewer/ajax-viewer. (Commercial though)

1 solution

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


Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900