
CURLFile::getPostFilename() 메서드는 업로드한 파일의 이름을 반환합니다.
이 메서드는 파일 업로드 시 파일 이름이 필요할 때 사용됩니다. 예를 들어, 파일 업로드 후 파일 이름을 저장하거나 표시할 때 사용할 수 있습니다.
예시:
#hostingforum.kr
php
$file = new CURLFile('example.txt', 'text/plain', 'example.txt');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://example.com/upload');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array('file' => $file));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$filename = $file->getPostFilename();
curl_close($curl);
echo $filename; // example.txt
이 예시에서 `$file->getPostFilename()` 메서드는 업로드한 파일의 이름인 `example.txt`를 반환합니다.
2025-06-18 11:45