By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

PHP: FTP problem

P: n/a
Hi experts and professionals.

My goal is to automatically download PDF files and convert them to
HTML using pdftohtml library.

Here is how it works:
1. It downloads PDF file using file_get_contents()
2. Uses pdftohtml library and perform conversion

My problem is when I'm trying to fetch PDF files from symantec FTP
server:
ftp://exftpp.symantec.com/pub/suppor...ver/279289.pdf

file_get_contents() fails with RETR response 425 (can't open
connection)

I tried curl library, and I get the same error. Here is my code:

*****
$pdf = "ftp://exftpp.symantec.com/pub/support/products/
NetBackup_Enterprise_Server/279289.pdf";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $pdf);
curl_setopt($ch, CURLOPT_HEADER, 0);

$str = curl_exec($ch);
if ($str === false)
echo "Can't get PDF file: <br/>" . curl_errno($ch) . ': ' .
curl_error($ch);
else
var_dump($str);

curl_close($ch);
*****

This code produces this output:

Can't get PDF file:
19: RETR response: 425

---------------
If you put this url to Mozilla browser, it successfully loads PDF
file. So I guess that I need to specify specific options to connect to
the FTP using curl.

I'm open to use any solution (not curl only). Just help me to
understand how to solve my problem.

Thanks,
Anton
Sep 28 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 28 Sep, 07:58, Meglio <x.meg...@gmail.comwrote:
Hi experts and professionals.

My goal is to automatically download PDF files and convert them to
HTML using pdftohtml library.

Here is how it works:
1. It downloads PDF file using file_get_contents()
2. Uses pdftohtml library and perform conversion

My problem is when I'm trying to fetch PDF files from symantec FTP
server:ftp://exftpp.symantec.com/pub/suppor...p_Enterprise_S...

file_get_contents() fails with RETR response 425 (can't open
connection)

I tried curl library, and I get the same error. Here is my code:

*****
$pdf = "ftp://exftpp.symantec.com/pub/support/products/
NetBackup_Enterprise_Server/279289.pdf";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $pdf);
curl_setopt($ch, CURLOPT_HEADER, 0);

$str = curl_exec($ch);
if ($str === false)
echo "Can't get PDF file: <br/>" . curl_errno($ch) . ': ' .
curl_error($ch);
else
var_dump($str);

curl_close($ch);
*****

This code produces this output:

Can't get PDF file:
19: RETR response: 425

---------------
If you put this url to Mozilla browser, it successfully loads PDF
file. So I guess that I need to specify specific options to connect to
the FTP using curl.

I'm open to use any solution (not curl only). Just help me to
understand how to solve my problem.

Thanks,
Anton
Is this a Mozilla browser running on the same machine where you are
trying to run your PHP code - otherwise the comment is meaningless -
try from the PHP server.

RTFM on file wrappers and safe_mode - or just see if you can open an
HTTP file using file_get_contents.

Use passive mode with curl.

If still broken - post again with the results for the above.

C.
Sep 28 '08 #2

P: n/a
On Sep 28, 12:31*pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 28 Sep, 07:58, Meglio <x.meg...@gmail.comwrote:
Hi experts and professionals.
My goal is to automatically download PDF files and convert them to
HTML using pdftohtml library.
Here is how it works:
1. It downloads PDF file using file_get_contents()
2. Uses pdftohtml library and perform conversion
My problem is when I'm trying to fetch PDF files from symantec FTP
server:ftp://exftpp.symantec.com/pub/suppor...p_Enterprise_S...
file_get_contents() fails with RETR response 425 (can't open
connection)
I tried curl library, and I get the same error. Here is my code:
*****
$pdf = "ftp://exftpp.symantec.com/pub/support/products/
NetBackup_Enterprise_Server/279289.pdf";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $pdf);
curl_setopt($ch, CURLOPT_HEADER, 0);
$str = curl_exec($ch);
if ($str === false)
* * * * echo "Can't get PDF file: <br/>" . curl_errno($ch) . ':' .
curl_error($ch);
else
* * * * var_dump($str);
curl_close($ch);
*****
This code produces this output:
Can't get PDF file:
19: RETR response: 425
---------------
If you put this url to Mozilla browser, it successfully loads PDF
file. So I guess that I need to specify specific options to connect to
the FTP using curl.
I'm open to use any solution (not curl only). Just help me to
understand how to solve my problem.
Thanks,
Anton

Is this a Mozilla browser running on the same machine where you are
trying to run your PHP code - otherwise the comment is meaningless -
try from the PHP server.

RTFM on file wrappers and safe_mode - or just see if you can open an
HTTP file using file_get_contents.

Use passive mode with curl.

If still broken - post again with the results for the above.

C.
1. Yes, this a Mozilla browser running on the same machine where I'm
trying to run my PHP code

2. Can't open using file_get_contents - getting warning "...RETR
response..."

3. Can you explain on how to apply this?
RTFM on file wrappers and safe_mode .
Use passive mode with curl.
Thanks
Sep 28 '08 #3

P: n/a
I just found that CURL uses passive by default
Sep 28 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.