Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Nov 2006
    Posts
    14

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

    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. #2
    Member
    Join Date
    Nov 2006
    Posts
    14

    Default

    Hi. Is there anyone who would have an idea about this problem?

  3. #3
    Member
    Join Date
    Jun 2006
    Posts
    212

    Default

    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?
    Alex Villegas

  4. #4
    Member
    Join Date
    Nov 2006
    Posts
    14

    Default

    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. #5
    Member
    Join Date
    Nov 2006
    Posts
    14

    Default

    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.

Similar Threads & Tags
Similar threads

  1. Multiple Account Transfers and files owned by user nobody
    By Curious Too in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 11-02-2009, 05:55 PM
  2. Question about PHP security, setting up multiple php.ini files?
    By sirbrent in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 10-01-2008, 10:58 AM
  3. Chowned All Files To User Root Please Help
    By mohdyasar in forum cPanel and WHM Discussions
    Replies: 11
    Last Post: 09-12-2006, 01:12 PM
  4. Chowned All Files To User Root Please Help
    By mohdyasar in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 09-12-2006, 10:34 AM
  5. PHP ftp_put commands fails with APF on
    By westhost-neil in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 04-24-2006, 06:26 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube