473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP: FTP problem

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
3 3726
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
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
I just found that CURL uses passive by default
Sep 28 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Robert | last post by:
Hi, I have a book that I've been using to learn PHP and MySQL. In it, it uses some code to show you how to use hidden fields which is not working correctly. The code I'm using is:...
3
by: Tyrone Slothrop | last post by:
The first question, is this even possible? What I need to do is pass the contents of a PHP web page from a textarea using window.open method to a new browser window and display it. The page has...
2
by: Robert Stearns | last post by:
After working well for most of a week, my application with the mysterious php/db2 problem is now failing again. No one has worked on the php code this week. We're running DB2 8.1.5, php 4.3.6...
1
by: Simon Lee | last post by:
Dear all, My php webpages can be ruun normally, However, when they are moved to the other server with Redhat 9, some following problems about php will occur, 1. when the webpage is linked to...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
4
by: comp.lang.tcl | last post by:
I wrote this PHP function in the hopes that it would properly use a TCL proc I wrote about 4 years ago: if (!function_exists('proper_case')) { /** * Ths function will convert a string into a...
5
by: fructose | last post by:
This is driving me crazy... I've spent, literally, a week trying to solve this (probably very silly) problem – to no avail. Help please! The code below shows the PHP with the relevant CSS for...
4
by: comp.lang.php | last post by:
I am trying to simply pipe in 2 very small commands and not have to create a PHP script to do this: However, I do not have the "-r" option in PHP 4.3.9, and I would think that I would, but...
4
by: jatrojoomla | last post by:
I am trying to work with SOAP with php. Even I also add line like $client = new SoapClient('./productSearchService.wsdl', array('trace'=true)); I found error every time like: Fatal...
1
by: Rorus4 | last post by:
Hello, I am having a problem installing the Dolphin Community Builder software manually on my free 000webhost.com account. The messages i'm getting are these: Warning: file_exists() :...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.