I have an upload script that accepts a .HTML file format. If the HTML text contains <img>
tags, I need to upload those image files to the server from the users hard drive. I'm trying to think of the best way to approach this.
I am using HTMLAgilityPack to search HTML for img tags:
List<string> allTags = new List<string>();
HtmlDocument doc = new HtmlDocument();
doc.Load(@"C:\Users\Mike\Documents\website.htm");
HtmlNodeCollection linkNodes = doc.DocumentNode.SelectNodes("//img");
// Run only if there are img in the document.
if (linkNodes != null)
{
foreach (HtmlNode linkNode in linkNodes)
{
HtmlAttribute attrib = linkNode.Attributes["src"];
string attribString = attrib.Value.ToString();
allTags.Add(attribString);
}
}
How can I upload each of the image files once they are found in the loop?