CLI CURL -> PHP CURL

后端 未结 3 705
深忆病人
深忆病人 2020-12-21 06:22

How can I translate this curl command so that it works in a PHP script?

curl --request POST --data-binary \'@import.xml\' --header \"Content-Type: applicatio         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-21 06:50

    $data = array('file'=> '@' . $filename);                    
    

    You need to prepend the filename with a '@' to tell CURL it's actually a filename and not just a string. The headers are not required either, as CURL will fill them in itself.

提交回复
热议问题