关键:当参数名为"@绝对路径",这时 CURL 會幫你做 multipart/form-data 編碼

 

实现方法:

$params = array(
    'file' => '@/Pictures/753161072647248225.jpg',
    'file_1' => '@/Pictures/753161072647248225.jpg',
    'file_2' => '@/Pictures/753161072647248225.jpg',
);

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
$response = curl_exec($ch);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2021-12-24
  • 2022-12-23
  • 2022-02-07
  • 2022-01-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案