gpt4 book ai didi

php - 如何使用 php-curl 发布存储在本地的二进制文件?

转载 作者:行者123 更新时间:2023-12-04 18:22:47 25 4
gpt4 key购买 nike

我希望使用 php-curl 发出以下 curl 请求:

curl "http://www.example.com/" -F "file=@foo.ext"

假设 foo.ext,我需要如何在 PHP 中进行设置(使用 curl_init、_setopt 等)住在我发出请求的机器上?

最佳答案

你会用

curl_setopt($curl_handle, CURLOPT_POST, TRUE);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, array('file' => '@foo.ext'));

加上您需要的任何选项。相关文档: http://php.net/curl_setopt

关于php - 如何使用 php-curl 发布存储在本地的二进制文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10322646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com