I have a Postman HTTP request using POST, a form data field of a file saved under the key plsm_xls_file[].
The file is in the local filesystem.
This request runs perfectly from POSTMAN but when I try to export it to PHP-Curl from the Code Snippets I get something like this:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://mydomain.nl/po_upload3.php?xlsimport=2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('plsm_xls_file[]'=> new CURLFILE('/C:/Users/myuser/Documents/vita_debug/201216_FG_PC_68715.xlsx'),'template_id' => '170'),
CURLOPT_HTTPHEADER => array(
'cookie: PHPSESSID=509e15pepo3ok80nd74jhdis33;'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
It's not working. It's like the file isn't properly attached to the HTTP request.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…