<tfoot id='7e73m'></tfoot>

<small id='7e73m'></small><noframes id='7e73m'>

    1. <i id='7e73m'><tr id='7e73m'><dt id='7e73m'><q id='7e73m'><span id='7e73m'><b id='7e73m'><form id='7e73m'><ins id='7e73m'></ins><ul id='7e73m'></ul><sub id='7e73m'></sub></form><legend id='7e73m'></legend><bdo id='7e73m'><pre id='7e73m'><center id='7e73m'></center></pre></bdo></b><th id='7e73m'></th></span></q></dt></tr></i><div id='7e73m'><tfoot id='7e73m'></tfoot><dl id='7e73m'><fieldset id='7e73m'></fieldset></dl></div>

    2. <legend id='7e73m'><style id='7e73m'><dir id='7e73m'><q id='7e73m'></q></dir></style></legend>

          <bdo id='7e73m'></bdo><ul id='7e73m'></ul>

        C# HttpClient 4.5 多部分/表单数据上传

        时间:2023-06-02
        <i id='AFo2o'><tr id='AFo2o'><dt id='AFo2o'><q id='AFo2o'><span id='AFo2o'><b id='AFo2o'><form id='AFo2o'><ins id='AFo2o'></ins><ul id='AFo2o'></ul><sub id='AFo2o'></sub></form><legend id='AFo2o'></legend><bdo id='AFo2o'><pre id='AFo2o'><center id='AFo2o'></center></pre></bdo></b><th id='AFo2o'></th></span></q></dt></tr></i><div id='AFo2o'><tfoot id='AFo2o'></tfoot><dl id='AFo2o'><fieldset id='AFo2o'></fieldset></dl></div>
        <legend id='AFo2o'><style id='AFo2o'><dir id='AFo2o'><q id='AFo2o'></q></dir></style></legend>
          • <bdo id='AFo2o'></bdo><ul id='AFo2o'></ul>

          • <tfoot id='AFo2o'></tfoot>

              <tbody id='AFo2o'></tbody>

              1. <small id='AFo2o'></small><noframes id='AFo2o'>

                  本文介绍了C# HttpClient 4.5 多部分/表单数据上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  有谁知道如何在 .Net 4.5 中使用 HttpClientmultipart/form-data 上传?

                  Does anyone know how to use the HttpClient in .Net 4.5 with multipart/form-data upload?

                  我在互联网上找不到任何示例.

                  I couldn't find any examples on the internet.

                  推荐答案

                  我的结果是这样的:

                  public static async Task<string> Upload(byte[] image)
                  {
                       using (var client = new HttpClient())
                       {
                           using (var content =
                               new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)))
                           {
                               content.Add(new StreamContent(new MemoryStream(image)), "bilddatei", "upload.jpg");
                  
                                using (
                                   var message =
                                       await client.PostAsync("http://www.directupload.net/index.php?mode=upload", content))
                                {
                                    var input = await message.Content.ReadAsStringAsync();
                  
                                    return !string.IsNullOrWhiteSpace(input) ? Regex.Match(input, @"http://w*.directupload.net/images/d*/w*.[a-z]{3}").Value : null;
                                }
                            }
                       }
                  }
                  

                  这篇关于C# HttpClient 4.5 多部分/表单数据上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 XSD 生成 C# 类 下一篇:将大文件上传到 ASP.NET MVC

                  相关文章

                  最新文章

                1. <tfoot id='hMNwz'></tfoot>

                  <i id='hMNwz'><tr id='hMNwz'><dt id='hMNwz'><q id='hMNwz'><span id='hMNwz'><b id='hMNwz'><form id='hMNwz'><ins id='hMNwz'></ins><ul id='hMNwz'></ul><sub id='hMNwz'></sub></form><legend id='hMNwz'></legend><bdo id='hMNwz'><pre id='hMNwz'><center id='hMNwz'></center></pre></bdo></b><th id='hMNwz'></th></span></q></dt></tr></i><div id='hMNwz'><tfoot id='hMNwz'></tfoot><dl id='hMNwz'><fieldset id='hMNwz'></fieldset></dl></div>
                  1. <legend id='hMNwz'><style id='hMNwz'><dir id='hMNwz'><q id='hMNwz'></q></dir></style></legend>

                      <small id='hMNwz'></small><noframes id='hMNwz'>

                        <bdo id='hMNwz'></bdo><ul id='hMNwz'></ul>