Re: Download remote PDF using php code

Stephen Pynenburg <[email protected]> Fri, 4 Aug 2017 09:17:45 -0400
Newsgroups gmane.comp.web.curl.php
Message-ID <CAPgVXYMgBJxevCT2Zn4_M8M++XXP4h4EAFJdzAhj6qMDcAX5dQ@mail.gmail.com>
--===============1587625337==
Content-Type: multipart/alternative; boundary="94eb2c05aab4b671460555ed52ce"

--94eb2c05aab4b671460555ed52ce
Content-Type: text/plain; charset="UTF-8"

Nour,
HTTP response code 0 means curl is not connecting to the server. I agree
with Atul - connect to the server using your web browser to ensure it is
actually online.
If your browser can connect but curl can't, call curl_error($curl) to
figure out what is going wrong.
Stephen

On Fri, Aug 4, 2017 at 7:22 AM, Atul Vaibhav <[email protected]>
wrote:

> Are you able to download the file from any other agent eg. Chrome or
> Firefox using exact link ?
>
> Thanks,
> Atul Vaibhav
> Noida
>
> On Thu, Aug 3, 2017 at 8:02 PM, Denis K <[email protected]> wrote:
>
>> Verify first off all what file hosts  in the public location
>>
>> On 3 Aug 2017 5:30 p.m., "Denis K" <[email protected]> wrote:
>>
>>> Look for pure downloading you just need denote to curl remote host and
>>> path to file and it could be perform downloading.
>>>
>>>
>>> On 3 Aug 2017 4:23 p.m., "Stephen Pynenburg" <[email protected]>
>>> wrote:
>>>
>>>> Hello Nour,
>>>> Some basic steps to try for debugging:
>>>> - is the PDF file on disk the same size as expected (i.e. how big is
>>>> the PDF)? If you are getting a much shorter response than expected, your
>>>> curl request is not receiving the PDF data and you need to find out why.
>>>> - what is the HTTP response code? (use curl_getinfo()). Are you missing
>>>> a redirect?
>>>> - does the server require some cookies or other state to access the
>>>> file?
>>>> - have you looked in the response headers? Is content-length the same
>>>> as expected?
>>>>
>>>> Stephen
>>>>
>>>> On Thu, Aug 3, 2017 at 7:59 AM, Nour Omar <[email protected]>
>>>> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I don't know, I'm not informed about it. I only used the code that i
>>>>> sent to you.
>>>>> Note: my pdf files contain designs (graphics).
>>>>> Can you please tell me what is missing that my code might work?
>>>>>
>>>>> Best regards
>>>>> Nour
>>>>>
>>>>> Sent from my iPhone
>>>>>
>>>>> > On Aug 3, 2017, at 12:33 PM, Nima Sadjadi <[email protected]>
>>>>> wrote:
>>>>> >
>>>>> > Had you set the header() of your output page correctly?
>>>>> >
>>>>> >
>>>>> > _______________________________________________
>>>>> > https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>>>>
>>>>> _______________________________________________
>>>>> https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>>>
>>>>
>> _______________________________________________
>> https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>
>>
>
> _______________________________________________
> https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>

--94eb2c05aab4b671460555ed52ce
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Nour,</div><div>HTTP response code 0 means curl is no=
t connecting to the server. I agree with Atul - connect to the server using=
 your web browser to ensure it is actually online. </div><div>If your brows=
er can connect but curl can&#39;t, call curl_error($curl) to figure out wha=
t is going wrong.</div><div>Stephen</div></div><div class=3D"gmail_extra"><=
br><div class=3D"gmail_quote">On Fri, Aug 4, 2017 at 7:22 AM, Atul Vaibhav =
<span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr">Are you able to download the file from any o=
ther agent eg. Chrome or Firefox using exact link ?</div><div class=3D"gmai=
l_extra"><br clear=3D"all"><div><div class=3D"m_2845481847530231796gmail_si=
gnature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=
=3D"ltr"><div><div dir=3D"ltr"><div dir=3D"ltr"><div><font face=3D"times ne=
w roman, serif" size=3D"2">Thanks,</font></div><div><font face=3D"times new=
 roman, serif" size=3D"2">Atul Vaibhav<br></font></div><div><font face=3D"t=
imes new roman, serif" size=3D"2">Noida</font></div></div></div></div></div=
></div></div></div></div>
<br><div class=3D"gmail_quote"><div><div class=3D"h5">On Thu, Aug 3, 2017 a=
t 8:02 PM, Denis K <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]=
" target=3D"_blank">[email protected]</a>&gt;</span> wrote:<br></div></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-=
left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-le=
ft-style:solid"><div><div class=3D"h5"><div dir=3D"auto">Verify first off a=
ll what file hosts =C2=A0in the public location=C2=A0</div><div class=3D"m_=
2845481847530231796HOEnZb"><div class=3D"m_2845481847530231796h5"><div clas=
s=3D"gmail_extra"><br><div class=3D"gmail_quote">On 3 Aug 2017 5:30 p.m., &=
quot;Denis K&quot; &lt;<a href=3D"mailto:[email protected]" target=3D"_blank=
">[email protected]</a>&gt; wrote:<br type=3D"attribution"><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-=
left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">=
<div dir=3D"auto">Look for pure downloading you just need denote to curl re=
mote host and path to file and it could be perform downloading. =C2=A0<div =
dir=3D"auto"><br></div></div><div class=3D"gmail_extra"><br><div class=3D"g=
mail_quote">On 3 Aug 2017 4:23 p.m., &quot;Stephen Pynenburg&quot; &lt;<a h=
ref=3D"mailto:[email protected]" target=3D"_blank">[email protected]<=
/a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,=
204,204);border-left-width:1px;border-left-style:solid"><div dir=3D"ltr"><d=
iv><div><div><div>Hello Nour,<br></div>Some basic steps to try for debuggin=
g:<br>- is the PDF file on disk the same size as expected (i.e. how big is =
the PDF)? If you are getting a much shorter response than expected, your cu=
rl request is not receiving the PDF data and you need to find out why.<br><=
/div>- what is the HTTP response code? (use curl_getinfo()). Are you missin=
g a redirect?<br></div>- does the server require some cookies or other stat=
e to access the file?<br></div>- have you looked in the response headers? I=
s content-length the same as expected?<br><div><div><div><div><br></div><di=
v>Stephen<br></div></div></div></div></div><div class=3D"gmail_extra"><br><=
div class=3D"gmail_quote">On Thu, Aug 3, 2017 at 7:59 AM, Nour Omar <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blan=
k">[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left=
-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Hell=
o,<br>
<br>
I don&#39;t know, I&#39;m not informed about it. I only used the code that =
i sent to you.<br>
Note: my pdf files contain designs (graphics).<br>
Can you please tell me what is missing that my code might work?<br>
<br>
Best regards<br>
Nour<br>
<br>
Sent from my iPhone<br>
<span><br>
&gt; On Aug 3, 2017, at 12:33 PM, Nima Sadjadi &lt;<a href=3D"mailto:nsadja=
[email protected]" target=3D"_blank">[email protected]</a>&gt; wrote:<br>
&gt;<br>
&gt; Had you set the header() of your output page correctly?<br>
&gt;<br>
&gt;<br>
</span>&gt; ______________________________<wbr>_________________<br>
&gt; <a href=3D"https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php"=
 target=3D"_blank" rel=3D"noreferrer">https://cool.haxx.se/cgi-bin/m<wbr>ai=
lman/listinfo/curl-and-php</a><br>
<br>
______________________________<wbr>_________________<br>
<a href=3D"https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php" targ=
et=3D"_blank" rel=3D"noreferrer">https://cool.haxx.se/cgi-bin/m<wbr>ailman/=
listinfo/curl-and-php</a><br>
</blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
<a href=3D"https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php" targ=
et=3D"_blank" rel=3D"noreferrer">https://cool.haxx.se/cgi-bin/m<wbr>ailman/=
listinfo/curl-and-php</a><br>
<br></blockquote></div></div>
</blockquote></div></div>
</div></div><br></div></div>______________________________<wbr>____________=
_____<br>
<a href=3D"https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php" targ=
et=3D"_blank" rel=3D"noreferrer">https://cool.haxx.se/cgi-bin/m<wbr>ailman/=
listinfo/curl-and-php</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
<a href=3D"https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php" targ=
et=3D"_blank" rel=3D"noreferrer">https://cool.haxx.se/cgi-bin/<wbr>mailman/=
listinfo/curl-and-php</a><br>
<br></blockquote></div><br></div>

--94eb2c05aab4b671460555ed52ce--

--===============1587625337==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KaHR0cHM6Ly9j
b29sLmhheHguc2UvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL2N1cmwtYW5kLXBocAo=

--===============1587625337==--