• <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 请求中写入多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  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>