[Html]
# Region download the image and upload it to the image server
Public string SaveUrlPics (string strHTML, string path)
{
String picserver = new CommonBLL (). GetItemValue ("PICSERVER"); // obtain the image server address
String [] imgurlAry = GetImgTag (strHTML); // obtain the image address in the document.
Try
{
WebClient wc = new WebClient ();
For (int I = 0; I {
// Temporarily handle this problem. Do not add it multiple times. Do not process the local machine.
If (imgurlAry [I]. IndexOf (picserver) <0)
{
String preStr = DateTime. Now. ToString ("yyyyMMddHHmmssfff ");
PreStr = preStr + imgurlAry [I]. Substring (imgurlAry [I]. LastIndexOf ("."); // obtain image attributes to generate image names
// The downloaded image is stored in the TEMP folder.
Wc. DownloadFile (imgurlAry [I], HttpContext. Current. Server. MapPath (path) + "/" + preStr );
// Upload the image to the image server
PreStr = picserver + "/" + upImg (preStr, dropArtType. SelectedValue );
StrHTML = strHTML. Replace (imgurlAry [I], preStr );
}
}
}
Catch (Exception ex)
{
ShowMessage (ex. Message );
}
Return strHTML;
}
# Endregion
# Region download the image and upload it to the image server
Public string SaveUrlPics (string strHTML, string path)
{
String picserver = new CommonBLL (). GetItemValue ("PICSERVER"); // obtain the image server address
String [] imgurlAry = GetImgTag (strHTML); // obtain the image address in the document.
Try
{
WebClient wc = new WebClient ();
For (int I = 0; I {
// Temporarily handle this problem. Do not add it multiple times. Do not process the local machine.
If (imgurlAry [I]. IndexOf (picserver) <0)
{
String preStr = DateTime. Now. ToString ("yyyyMMddHHmmssfff ");
PreStr = preStr + imgurlAry [I]. Substring (imgurlAry [I]. LastIndexOf ("."); // obtain image attributes to generate image names
// The downloaded image is stored in the TEMP folder.
Wc. DownloadFile (imgurlAry [I], HttpContext. Current. Server. MapPath (path) + "/" + preStr );
// Upload the image to the image server
PreStr = picserver + "/" + upImg (preStr, dropArtType. SelectedValue );
StrHTML = strHTML. Replace (imgurlAry [I], preStr );
}
}
}
Catch (Exception ex)
{
ShowMessage (ex. Message );
}
Return strHTML;
}
# Endregion