Why is FTP upload failing?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    Why is FTP upload failing?

    Hi,

    I'm using PHP 4.4.4 with Apahce 2.2 on Fedora Core 5 Linux. I'm having
    trouble figuring out why an ftp_put call is failing. Is there a way I
    can get an exact reason other than checking whether it has succeeded or
    failed?

    Here is my code

    $conn_id = ftp_connect($ft p_host);
    if ($conn_id) {
    // login with username and password
    $login_result = ftp_login($conn _id,
    $ftp_user, $ftp_pwd);
    if ($login_result) {
    // Disable passive mode
    ftp_pasv($conn_ id, false);

    // upload the file
    $remote_path = "$ftp_dir/" .
    SQL_PRODUCT_SHO RT_FILE_NAME;
    $upload = ftp_put($conn_i d,
    $remote_path, $sql_file_path, FTP_ASCII);

    // check upload status
    if (!$upload) {
    die("FTP upload has
    failed!");

    I'm getting the message "FTP upload has failed" indicating things haev
    died. Still don't know why.

    Thanks, - Dave

  • Joseph Dougherty

    #2
    Re: Why is FTP upload failing?

    Usually the mistake I end up making is either related to permissions
    (i.e. the permissions your webserver has to PHP's temporary directory)
    or related to the file size limitations (as defined in the php.ini file).

    I would start there. The php.ini file on Linux (and of course this is
    not true for all ditros) is usually in /etc/php/ or /etc/php4

    HTH

    Comment

    • laredotornado@zipmail.com

      #3
      Re: Why is FTP upload failing?

      Thanks. What directives in php.ini am I looking for exactly? THe file
      I was trying to FTP was a little over 1M, so I can see that being a
      potential problem but not sure what the setting to adjust is.

      - Dave

      Joseph Dougherty wrote:
      Usually the mistake I end up making is either related to permissions
      (i.e. the permissions your webserver has to PHP's temporary directory)
      or related to the file size limitations (as defined in the php.ini file).
      >
      I would start there. The php.ini file on Linux (and of course this is
      not true for all ditros) is usually in /etc/php/ or /etc/php4
      >
      HTH

      Comment

      • clashers5@gmail.com

        #4
        Re: Why is FTP upload failing?

        My php.ini file has an entire section dedicated to file uploads:

        -------->>CODE<<--------
        ;;;;;;;;;;;;;;; ;
        ; File Uploads ;
        ;;;;;;;;;;;;;;; ;

        ; Whether to allow HTTP file uploads.
        file_uploads = On

        ; Temporary directory for HTTP uploaded files (will use system
        default if not
        ; specified).
        ;upload_tmp_dir =

        ; Maximum allowed size for uploaded files.
        upload_max_file size = 2M
        -------->>END CODE<<--------

        HTH


        laredotornado@z ipmail.com wrote:
        Thanks. What directives in php.ini am I looking for exactly? THe file
        I was trying to FTP was a little over 1M, so I can see that being a
        potential problem but not sure what the setting to adjust is.
        >
        - Dave
        >
        Joseph Dougherty wrote:
        Usually the mistake I end up making is either related to permissions
        (i.e. the permissions your webserver has to PHP's temporary directory)
        or related to the file size limitations (as defined in the php.ini file).

        I would start there. The php.ini file on Linux (and of course this is
        not true for all ditros) is usually in /etc/php/ or /etc/php4

        HTH

        Comment

        • Andy Hassall

          #5
          Re: Why is FTP upload failing?

          On 14 Nov 2006 15:28:58 -0800, "clashers5@gmai l.com" <clashers5@gmai l.com>
          wrote:
          >My php.ini file has an entire section dedicated to file uploads:
          >
          >-------->>CODE<<--------
          ;;;;;;;;;;;;;;; ;
          ; File Uploads ;
          ;;;;;;;;;;;;;;; ;
          >
          ; Whether to allow HTTP file uploads.
          file_uploads = On
          >
          ; Temporary directory for HTTP uploaded files (will use system
          >default if not
          ; specified).
          ;upload_tmp_dir =
          >
          ; Maximum allowed size for uploaded files.
          upload_max_file size = 2M
          >-------->>END CODE<<--------
          That's for HTTP file uploads which PHP would receive and process from a client
          - not FTP file uploads which PHP may initiate to another server, but wouldn't
          typically process itself (you'd have to be running an FTP daemon written in PHP
          which would be unusual).

          --
          Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
          http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

          Comment

          • Andy Hassall

            #6
            Re: Why is FTP upload failing?

            On 13 Nov 2006 11:35:59 -0800, "laredotornado@ zipmail.com"
            <laredotornado@ zipmail.comwrot e:
            $upload = ftp_put($conn_i d,
            >$remote_path , $sql_file_path, FTP_ASCII);
            >
            // check upload status
            if (!$upload) {
            die("FTP upload has
            >failed!");
            >
            >I'm getting the message "FTP upload has failed" indicating things haev
            >died. Still don't know why.
            Do you have error_reporting cranked up to maximum and display_errors turned
            on?

            --
            Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
            http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

            Comment

            • laredotornado@zipmail.com

              #7
              Re: Why is FTP upload failing?

              I do. In my php.ini file I have

              error_reporting = E_ALL

              and

              display_errors = On

              - Dave

              Andy Hassall wrote:
              On 13 Nov 2006 11:35:59 -0800, "laredotornado@ zipmail.com"
              <laredotornado@ zipmail.comwrot e:
              >
              $upload = ftp_put($conn_i d,
              $remote_path, $sql_file_path, FTP_ASCII);

              // check upload status
              if (!$upload) {
              die("FTP upload has
              failed!");

              I'm getting the message "FTP upload has failed" indicating things haev
              died. Still don't know why.
              >
              Do you have error_reporting cranked up to maximum and display_errors turned
              on?
              >
              --
              Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
              http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

              Comment

              Working...