复制代码 代码如下:
if (FileUpload1.PostedFile.FileName == "")
{
Response.Write("<script>alert('请确定您是否选择了网页')</script>");
return;
}
if ((FileUpload1.FileName.LastIndexOf(".") != "htm") || (FileUpload1.FileName.LastIndexOf(".") != "html"))
{
Response.Write("<script>alert('请确定您是否选择了网页')</script>");
return;
}
System.Text.Encoding ec = System.Text.Encoding.GetEncoding("gb2312");//指定编码格式
System.IO.StreamReader sr = new System.IO.StreamReader(FileUpload1.PostedFile.FileName, ec);
string strHTML =Convert.ToString(sr.ReadToEnd());
strHTML=FormatStr(strHTML); //格式化HTML代码后,将此strHTML插入数据库 已便使用时候提取!
sr.Close();
//贴上格式化HTML方法代码
/// <summary>
/// 格式 化 HTML
/// </summary>
/// <param></param>
/// <returns></returns>
private string FormatStr(string str)
{
string strContent = str.Replace("<", "<");
strContent = strContent.Replace(">", ">");
//strContent = strContent.Replace(chr(13),"<br>");
strContent = strContent.Replace("/r", "<br>");
strContent = strContent.Replace(" ", " ");
strContent = strContent.Replace("[isOK]", "<img src=");
strContent = strContent.Replace("[b]", "<b>");
strContent = strContent.Replace("[red]", "<font color=CC0000>");
strContent = strContent.Replace("[big]", "<font size=7>");
strContent = strContent.Replace("[/isOK]", "></img>");
strContent = strContent.Replace("[/b]", "</b>");
strContent = strContent.Replace("[/red]", "</font>");
strContent = strContent.Replace("[/big]", "</font>");
return strContent;
}
新闻热点
疑难解答
图片精选