0

Following is the HTML form code, for uploading text value and a JPEG file.

<html>
<head></head>

<body>
<form action="https://mywebsiteforexample.com/"  method="post"  enctype="multipart/form-data">
<input type="text" name="id" value="01"/>
<input type="file" name="image">
<input type="submit" value="send">

</form>

</body>
</html>

Problem is whenever I have to upload the file on server, I need to manually browse the file to upload it. I want to write the same code in C# so when I run the code it itself select the file by path given, and upload the file so I don't need to browse and select the file manually. Is it possible.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
siddstuff
  • 1,215
  • 4
  • 16
  • 37

1 Answers1

0

You don't need to write code that fills input elements (if you want, use Selenium with C# driver). Just simulate POST action from simple console application using for e.g. HttpClient.

There are plenty of questions on SO how to do it, e.g. C# HttpClient 4.5 multipart/form-data upload

Community
  • 1
  • 1
csharpfolk
  • 4,124
  • 25
  • 31