BIG
File send sample code using PHP curl
<?php
$cfile = curl_file_create('path/to/file.ext');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://example.com/upload",
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('file' => $cfile),
CURLOPT_HTTPHEADER => array(
"Content-Type: multipart/form-data"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
LIST
'!!...PHP > !!...SAMPLE' 카테고리의 다른 글
[PHP]18_입력받은 문자열에서 숫자만 추출하기 (0) | 2023.09.05 |
---|---|
[PHP]17_MariaDB 저장 프로시져 호출 sample code (0) | 2023.02.14 |
[PHP]15_http reqeust sample code (0) | 2023.02.08 |
[PHP]14_openai API ( chatGPT )연동 샘플 코드 (0) | 2023.02.08 |
[PHP]13_shell_exec Sample Code (0) | 2022.12.23 |