Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Ajax
- date
- 무료다운로드쿠폰
- 웹하드순위
- Linux
- UTF-8
- OOP
- 전략
- php
- Forms
- file-upload
- function
- variables
- composer-php
- Regex
- jquery
- 경영
- Laravel
- Arrays
- post
- JavaScript
- Session
- Apache
- 웹하드추천
- MySQL
- HTML
- curl
- JSON
- string
Archives
- Today
- Total
개발! 딱 깔끔하고 센스있게!
PHP + PDF, curl 다운로드하는 PDF 어떻게 사용합니까? 본문
어서 오세요.
내가 페이지에 다운로드한 pdf 파일을 저장할 때 문제가 있습니다.
pdf 를 다운로드하려면 Curl 사용하기:
$CurlConnect = curl_init(); curl_setopt($CurlConnect, CURLOPT_URL, 'http://website.com/invoices/download/1'); curl_setopt($CurlConnect, CURLOPT_POST, 1); curl_setopt($CurlConnect, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($CurlConnect, CURLOPT_POSTFIELDS, $request); curl_setopt($CurlConnect, CURLOPT_USERPWD, $login.':'.$password); $Result = curl_exec($CurlConnect);
현재 Result (string) 에서 모든 PDF 파일이 있습니다.
이제부터 나의 문제.다운로드를 저장하고 싶은 pdf:
header('Cache-Control: public'); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="new.pdf"'); header('Content-Length: '.filesize($Result)); readfile($Result);
불행한 것은 내가 저장하거나 새 PDF 파일을 열 때 공백문서를 얻을 수 있다는 것이다.
마지막 줄에 문제가 있을 수도 있습니다:
header('Content-Length: '.filesize($Result)); readfile($Result);
불행하게도, 나는 그들을 어떻게 바꾸어야 할지 모르겠어.나는 너의 도움을 청한다.
감사합니다.
대답
filesize, readfile 모두 파일을 인자로 받습니다.
파일이 아닌 문자열을 제공합니다.
이것 좀 해 보세요.
$CurlConnect = curl_init(); curl_setopt($CurlConnect, CURLOPT_URL, 'http://website.com/invoices/download/1'); curl_setopt($CurlConnect, CURLOPT_POST, 1); curl_setopt($CurlConnect, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($CurlConnect, CURLOPT_POSTFIELDS, $request); curl_setopt($CurlConnect, CURLOPT_USERPWD, $login.':'.$password); $Result = curl_exec($CurlConnect); header('Cache-Control: public'); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="new.pdf"'); header('Content-Length: '.strlen($Result)); echo $Result;
'개발 스크랩 메모 > PHP' 카테고리의 다른 글
WAMP 서버가 새로 설치되었을 때 Apachee / PHP 버전을 바꿀 때 오류가 발생했습니다 (0) | 2020.12.22 |
---|---|
응답을 기다리지 않는 php 요청 url (0) | 2020.12.22 |
php 그림 편집 (0) | 2020.12.22 |
select form my sql spesic 열에 복사상자를 삽입한 PHP 코드 (0) | 2020.12.22 |
PHP&HTML: 그림을 포함하는 디렉토리에서 순환합니까? (0) | 2020.12.22 |
Comments