【问题标题】:Send file using http post in c#在c#中使用http post发送文件
【发布时间】:2013-04-03 05:42:47
【问题描述】:

我正在使用 c# 处理文件发布。我使用 ajax 从客户端发布了一个文件,代码如下

<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" />

在服务器端,我使用代码检索了该文件,

 HttpPostedFile hpf = Request.Files[0];

我需要使用 http post 将此文件发送到另一个域。是否可以使用 http post 发送该 hpf?

【问题讨论】:

    标签: c# .net http-post


    【解决方案1】:

    我认为你应该能够做到这一点。有很多方法可以做到这一点。这是一个链接Upload files with HTTPWebrequest (multipart/form-data)

    【讨论】:

      猜你喜欢
      • 2013-03-22
      • 2010-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-02
      • 2023-04-02
      • 1970-01-01
      • 2011-08-15
      相关资源
      最近更新 更多