How to send upload file to other website by using curl in php?

前端 未结 2 433
栀梦
栀梦 2021-01-16 12:07

How does one upload a file to another website by using Curl in PHP and get the response page?

The website: http://www.postto.me

2条回答
  •  Happy的楠姐
    2021-01-16 12:34

    Here's an example of how to upload a file. (First hit for "curl file upload example php".)

    
        $post = array(
            "file_box"=>"@/path/to/myfile.jpg",
        );
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
        $response = curl_exec($ch);
    ?>
    

提交回复
热议问题