[PHP] Curl 을 이용하여 파일 다운로드

- 01-19
- 6,163 회
- 0 건
저장할 파일명 : $file
다운로드 받을 주소 : $url
[code]<br /> $file = './abc.txt';<br /> $url = '<A HREF="https://abc.com/abc.txt';" TARGET="_blank" rel="nofollow">https://abc.com/abc.txt';</A> $fp = fopen($data_dir.'/'.$filename, 'wb');<br /> $ch = curl_init($url);<br /> curl_setopt($ch, CURLOPT_TIMEOUT, 60);<br /> curl_setopt($ch, CURLOPT_FILE, $fp);<br /> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);<br /> curl_exec($ch);<br /> curl_close($ch);<br /> fclose($fp);<br /> [/code]
로그인 후 댓글내용을 입력해주세요