Похожие чаты

Hi all still on the issue of trying to send

a Pdf file to an Api...I have problem with the body actually working in the php code...I want to send the pdf file as json encoded to the api adress but it says not able to handle request...the code works without adding the body...kindly check and see if I am doing something wrong. Thanks in advance. <?php





$request = "https.....xxxxx; //

$headers = array(
"Authorization: Bearer xxxxxxxxx",
//'cache-control => no-cache',
//'content-type => multipart/form-data',
"Content-Type: application/json",
"Accept: application/json",
);

$body = array(
//"voucher_data": "base64_encode("frmUpload")",
"voucher_data": base64_encode(file_get_contents($_FILES["frmUpload"]["tmp_name"]));
"callback_url": "http://xxxxxxx",
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch,CURLOPT_HTTPHEADER,array($headers));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, array($body));
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$results= curl_exec($ch);


if(isset($_FILES['file'])){
$errors= array();
$file_name = $_FILES['file']['name'];
$file_size =$_FILES['file']['size'];
$file_tmp =$_FILES['file']['tmp_name'];
$file_type=$_FILES['file']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['file']['name'])));

$extensions= array("jpeg","jpg","png","pdf");

if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a Pdf file.";
}

if($file_size >= 4097152){
$errors[]='File size must not be greater than 3MB';
}

if(empty($errors)==true){
move_uploaded_file($file_tmp,"files/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}


?>

1 ответов

10 просмотров

how do you initiate the $body array?

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта