The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP ftp_put() multiple files works with root but not with user. Weird.

Discussion in 'General Discussion' started by infocom, May 6, 2007.

  1. infocom

    infocom Member

    Joined:
    Nov 21, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    I have a strange problem with PHP ftp_put().

    I have written a php script to FTP some files to another server. If I run the script as the root user it works fine. But when I run this as the actual Cpanel user, it only transfers one file, and does not FTP the rest. It fails at the ftp_put() command on the second and subsequent files.

    Anyone know why this is? Is there perhaps a limit to the file size a normal user can ftp, or the amount of files or something?

    Thanks

    Infocom
     
  2. infocom

    infocom Member

    Joined:
    Nov 21, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Hi. Is there anyone who would have an idea about this problem?
     
  3. AlexV.

    AlexV. Well-Known Member

    Joined:
    Jun 15, 2006
    Messages:
    212
    Likes Received:
    1
    Trophy Points:
    16
    Infocom:

    You can find certain resctrictions at the PHP configuration level, ie php.ini

    For example:
    ; Maximum allowed size for uploaded files.
    upload_max_filesize = "2M" ;upload_max_filesize

    Do you have any error logs or error messages?
     
  4. infocom

    infocom Member

    Joined:
    Nov 21, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    So would that restriction affect size/number of files you upload to another server via PHP's ftp_put()?

    It does not give me any error, other than my own error. So I have the command setup similar to this:-

    Code:
    $upload = ftp_put($conn_id, $ftp_file, $filename, FTP_BINARY);
    if (!$upload)
    { 
    	echo "FTP upload of ".$filename." has failed!<br><br>";
    }
    else
    {
    	echo "Uploaded ".$filename." to ".$ftp_server." as ".$file."<br><br>";
    }
    
    It goes through a foreach loop for each each file. As stated the first one goes fine but not the rest. Works fine when running as root.

    Thanks
    Infocom
     
  5. infocom

    infocom Member

    Joined:
    Nov 21, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Sorry for the late reply on this but I found the problem....

    The files I uploaded that I want to FTP are uploaded using some CMS for the website. So they have owner of "nobody". So when the CPanel user trys to FTP they don't have permission. So I had to change the upload script to change chmod to 777 after they upload. Works OK now.
     
Loading...

Share This Page