Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    151
    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:
    151
    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:
    168
    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?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. infocom

    infocom Member

    Joined:
    Nov 21, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    151
    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:
    151
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice