復制代碼 代碼如下:
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;
}
新聞熱點
疑難解答
圖片精選