I am automating the process of http post using HttpWebRequest
in asp.net mvc.
Basically if the Http post is successful, it will write all the post value into a database or a file.
It works well with simple types such as strings,int, datetime. But I am not sure how to create a query string from a image,or other files such as .doc
,.pdf
...
When doing a file upload manually, the input value of the file will be UploadedFile:****.JPG
; After choosing a local file ,for the http post I can do
string mimeType = Request.Files[upload].ContentType;
Stream fileStream = Request.Files[upload].InputStream;
string fileName = Path.GetFileName(Request.Files[upload].FileName);
int fileLength = Request.Files[upload].ContentLength;
byte[] fileData = new byte[fileLength];
fileStream.Read(fileData, 0, fileLength);
...
But I am doing the automating so I guess I need a query string something like field1=value1&field2=value2&UploadedFile=****.JPG
;But I think the process won't work as the web page had no idea where the image is. So any ideas to use a phicical Url to locate the image or any file so that I can convert it to byte array and manipulate it ?