English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
(PHP 5 >= 5.5.0)
curl_file_create — CURLFile 객체 생성
CURLFile curl_file_create ( string $filename [, string $mimetype [, string $postname ]])
업로드 파일을 위해 CURLFile 객체 생성
filename
업로드 파일의 경로
mimetype
파일의 Mimetype
postname
파일 이름
CURLFile 객체 반환
curl_file_create() 예제
<?php /* http://example.com/upload.php: <?php var_dump($_FILES); ?> */ // CURL 핸들 생성 $ch = curl_init('http://example.com/upload.php'); // CURLFile 객체 생성 $cfile = curl_file_create('cats.jpg','image/jpeg','test_name'); // POST 데이터 설정 $data = array('test_file' => $cfile); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // executor 핸들 curl_exec($ch); ?>
이 예제는 다음과 같이 출력됩니다:
array(1) { ["test_file"]=> array(5) { ["name"]=> string(9) "test_name" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpPC9Kbx" ["error"]=> int(0) ["size"]=> int(46334) } }