Write Multiple files in a single CURL request

前端 未结 3 1370
無奈伤痛
無奈伤痛 2020-12-17 03:29

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 =          


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-17 04:00

    A complete example would look something like this :

    "@/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);
    
    
    ?>
    

提交回复
热议问题