0

In recieiving html input from a user(rich text editor) , I would like to limit the amount of images they have submitted. Is there a way to allow the first few images and then remove the rest?

The images are in the form

  <img src="">
user3591017
  • 103
  • 7
  • 1
    Please Refer: http://stackoverflow.com/questions/9813556/count-and-limit-the-number-of-files-uploaded-html-file-input – Jatin Jan 20 '15 at 21:07
  • @Jatin, thanks for that link. Flagged as duplicate. – Spencer D Jan 20 '15 at 21:13
  • Oh I should clarify, I'm not allowing users to upload pictures. They are in the form , the other post doesn't help me. Please re open the question – user3591017 Jan 20 '15 at 21:15

1 Answers1

3

If you are looking to do this server side, use the HTMLAgilityPack. You can give it the HTML content and query this, in your case you'd want a list of all html images. Using this list, you could verify the count, remove elements etc. Example(using links, not images in this sample of code):

 HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
 TextReader TR= new StringReader(SomeText);
 doc.Load(TR);
 HtmlNodeCollection collection = doc.DocumentNode.SelectNodes("//a[@href]");
jayess
  • 56
  • 2