需要帮助上传docx文件并显示相同的内容 [英] Need help in uploading docx file and display the same

查看:109
本文介绍了需要帮助上传docx文件并显示相同的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



像naukri和其他工作门户网站我想上传文件,当我点击查看时,它应该显示下面的简历..



请告诉我该怎么做



谢谢

解决方案

您需要使用Word Interop dll编写自己的代码,以从word文档中读取文本和格式并从中创建HTML。然后,您可以将生成的HTML文件加载到页面中的iframe中。



选中 link [ ^ ]它不是免费的..

要上传docx文件,请使用下面的代码,



 protected void Button1_Click(object sender,EventArgs e)
{
if(FileUpload1.HasFile&& FileUpload1.PostedFile!= null)
{
int ilength =
Convert.ToInt32(FileUpload1.PostedFile.ContentLength) ;
string content = FileUpload1.PostedFile.ContentType;
string file_name = FileUpload1.FileName;
Byte [] bytecontent = new Byte [ilength];

con = new SqlConnection();
con.ConnectionString =Server = sqlserver;
Database = master; Trusted_Connection = True;
con.Open();

string sql =插入
文件(file_data,name,content_type,file_size)VALUES(@ file,@ name,@ content,
@size);
try
{
SqlCommand cmd = new SqlCommand(sql,con);
FileUpload1.PostedFile.InputStream.Read(bytecontent,0,
FileUpload1.PostedFile.ContentLength);
cmd.Parameters.AddWithValue(@ file,bytecontent);
cmd.Parameters.AddWithValue(@ name,file_name);
cmd.Parameters.AddWithValue(@ content,content);
cmd.Parameters.AddWithValue(@ size,ilength);
int i = cmd.ExecuteNonQuery();
TextBox1.Text = i.ToString();
}
catch(exception ex)
{
TextBox1.Text = ex.Message;
}
最后
{
con.Close();
}

}





要显示它,你必须添加



< a href =您的文件路径runat =serverid =filedisplay/> 


Hi all

Like naukri and other job portals i want to upload the file and when i click view it should display the resume below..

Please tell me how to do that

Thank you

解决方案

You will need to write your own code using Word Interop dlls to read the text and the formatting from word documents and create HTML from them. Then you can load the generated HTML file into a iframe in the page.

Check this link[^] Its not free..


To upload a docx file use below code,

protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile && FileUpload1.PostedFile != null)
{
int ilength =
Convert.ToInt32(FileUpload1.PostedFile.ContentLength);
string content = FileUpload1.PostedFile.ContentType;
string file_name = FileUpload1.FileName;
Byte[] bytecontent = new Byte[ilength];

con = new SqlConnection();
con.ConnectionString = "Server=sqlserver;
Database=master; Trusted_Connection=True";
con.Open();

string sql = "insert into
files(file_data,name,content_type,file_size)VALUES(@file, @name, @content,
@size)";
try
{
SqlCommand cmd = new SqlCommand(sql, con);
FileUpload1.PostedFile.InputStream.Read(bytecontent, 0,
FileUpload1.PostedFile.ContentLength);
cmd.Parameters.AddWithValue("@file", bytecontent);
cmd.Parameters.AddWithValue("@name", file_name);
cmd.Parameters.AddWithValue("@content", content);
cmd.Parameters.AddWithValue("@size", ilength);
int i = cmd.ExecuteNonQuery();
TextBox1.Text = i.ToString();
}
catch (Exception ex)
{
TextBox1.Text = ex.Message;
}
finally
{
con.Close();
}

}



To display it you have to add

<a href="your file path" runat="server" id="filedisplay" />


这篇关于需要帮助上传docx文件并显示相同的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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