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

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

        <tfoot id='Q0Fd5'></tfoot>
      1. 在单个 CURL 请求中写入多个文件

        时间:2023-10-12
        <tfoot id='5Tgcv'></tfoot>
        • <small id='5Tgcv'></small><noframes id='5Tgcv'>

            <tbody id='5Tgcv'></tbody>
          <i id='5Tgcv'><tr id='5Tgcv'><dt id='5Tgcv'><q id='5Tgcv'><span id='5Tgcv'><b id='5Tgcv'><form id='5Tgcv'><ins id='5Tgcv'></ins><ul id='5Tgcv'></ul><sub id='5Tgcv'></sub></form><legend id='5Tgcv'></legend><bdo id='5Tgcv'><pre id='5Tgcv'><center id='5Tgcv'></center></pre></bdo></b><th id='5Tgcv'></th></span></q></dt></tr></i><div id='5Tgcv'><tfoot id='5Tgcv'></tfoot><dl id='5Tgcv'><fieldset id='5Tgcv'></fieldset></dl></div>

                <bdo id='5Tgcv'></bdo><ul id='5Tgcv'></ul>
              • <legend id='5Tgcv'><style id='5Tgcv'><dir id='5Tgcv'><q id='5Tgcv'></q></dir></style></legend>

                • 本文介绍了在单个 CURL 请求中写入多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法使用 PHP curl 在单个请求中发送多个文件?

                  Is there a way using PHP curl to send multiple files in a single request?

                  我知道您可以使用以下方式发送单个文件:

                  I understand you can send a single file making use of the following:

                  $fh = fopen("files/" . $title . "/" . $name, "w");
                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_URL, trim($url));
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                  curl_setopt($ch, CURLOPT_FILE, $fh);
                  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");
                  curl_exec($ch);
                  echo curl_error($ch);
                  curl_close($ch);
                  

                  但我希望能够使用单个请求编写 3 个文件.

                  But I want to be able to write lets say 3 files using a single request.

                  有没有办法在 curl_exec() 之前将字节写入请求?

                  Is there maybe a way to write bytes to the request before the curl_exec()?

                  推荐答案

                  一个完整的例子应该是这样的:

                  A complete example would look something like this :

                  <?php
                  $xml = "some random data";
                  $post = array(
                       "uploadData"=>"@/Users/whowho/test.txt", 
                       "randomData"=>$xml, 
                  );
                  
                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_URL, trim("http://someURL/someTHing"));
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                  curl_setopt($ch, CURLOPT_POST, 1);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
                  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");
                  curl_exec($ch);
                  echo curl_error($ch);
                  curl_close($ch);
                  
                  
                  ?>
                  

                  这篇关于在单个 CURL 请求中写入多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:防止在 PHP 中的大请求期间超时 下一篇:php http 请求内容原始数据 enctype=multipart/form-data

                  相关文章

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

                  2. <small id='uk1ME'></small><noframes id='uk1ME'>

                      <tfoot id='uk1ME'></tfoot>

                      <legend id='uk1ME'><style id='uk1ME'><dir id='uk1ME'><q id='uk1ME'></q></dir></style></legend>
                        <bdo id='uk1ME'></bdo><ul id='uk1ME'></ul>