• <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 请求中写入多个文件

        Write Multiple files in a single CURL request(在单个 CURL 请求中写入多个文件)
        <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 请求中写入多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                  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>

                        <tbody id='uk1ME'></tbody>
                    • <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>