1
에 컬을 통해 업로드 :파일 게시물 /이 내 컬 개시 코드 PHP
$target="url/curlUploadHandler.php";
$args = new CURLFile('down.png', 'image/png','test'); //file to post
$postFields = array('file' => $args);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $target);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data'));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl,CURLOPT_SAFE_UPLOAD, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
$r = curl_exec($curl);
curl_close($curl);
print_r($r); // to get response from the page
그리고 이것은 주어진 파일을 게시 여부를 지 여부를 확인하는 것입니다
curlUploadHandler.php을
if($_REQUEST){ var_dump($_REQUEST); }
또는
if($_FILES) {
var_dump($_FILES);}
이 코드는 로컬에서 테스트하고 있습니다. 문자열 또는 정수와 같은 게시 필드는 정상적으로 작동하지만 이미지 나 다른 파일을 게시하면 출력이 나오지 않습니다. cURL
에 몇 가지 옵션이 누락되었거나 잘못된 것이 있습니까? 이미 php docs 문서를 확인했습니다. 제발 도와주세요.
그리고 downvoting하기 전에 의견을하시기 바랍니다 :/당신이