user1969752
user1969752

Reputation:

Send file using http post in c#

I am working with file posting in c#. I have posted a file from client side using ajax, with the following code

<script type="text/javascript">
  function send() {
    var fd = new FormData();
    fd.append("fileToUpload", document.getElementById('filecontrol').files[0]);
    var xhr = new XMLHttpRequest();
    xhr.open("POST", "getFile.aspx");
    xhr.send(fd);
      }
</script>
<input type="file" id="filecontrol" />
<input type="button" onclick="getFile()" value="Upload File" />

and in the server side, i retrieved that file using the code,

 HttpPostedFile hpf = Request.Files[0];

I need to send this file to another domain using http post. Is it possible to send that hpf using http post?.

Upvotes: 1

Views: 5497

Answers (1)

qamar
qamar

Reputation: 1447

I think you should be able to do that. There are many ways to do that. here is a link Upload files with HTTPWebrequest (multipart/form-data)

Upvotes: 1

Related Questions