How to send the file using curl in php
Get the solution ↓↓↓I had tried to send the file for pdf conversion using curl., but i got error from API side.
$file_name_with_full_path = WWW_ROOT . "img/IPG_07_12_2020.xlsx";
if (function_exists('curl_file_create')) {
$cFile = curl_file_create($file_name_with_full_path);
} else {
$cFile = '@' . realpath($file_name_with_full_path);
}
$post = array('file_contents'=> curl_file_create($file_name_with_full_path));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://localhost:3000/convert/office",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 86400,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_POSTFIELDS =>$post,
CURLOPT_HTTPHEADER => array('Content-Type: multipart/form-data'),
));
$result = curl_exec($curl);
and the error was {"message":"context has timed out"}., please share your knowledge to send the file to curl in proper way. Thanks in advance.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: deprecated: directive 'allow_url_include' is deprecated in unknown on line 0
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.