PHP: FTP problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Meglio

    #1

    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_conten ts()
    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_conten ts() 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_Enter prise_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
  • C. (http://symcbean.blogspot.com/)

    #2
    Re: PHP: FTP problem

    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_conten ts()
    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_conten ts() 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_Enter prise_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_conten ts.

    Use passive mode with curl.

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

    C.

    Comment

    • Meglio

      #3
      Re: PHP: FTP problem

      On Sep 28, 12:31 pm, "C. (http://symcbean.blogsp ot.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_conten ts()
      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_conten ts() 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_Enter prise_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_conten ts.
      >
      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_conten ts - 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

      Comment

      • Meglio

        #4
        Re: PHP: FTP problem

        I just found that CURL uses passive by default

        Comment

        Working...