Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: ftp_fput

  1. #1
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts

    ftp_fput

    Morning all im back.

    here is my code:

    PHP Code:
        $filesQuery mysql_query("SELECT * FROM `files` ORDER BY id") or die(mysql_error());
        
    $x=0;
        
    $z=0;
        
    $conn_id ftp_connect($FTPhost);
        
    $login_result ftp_login($conn_id$FTPuser$FTPpass);
        
        while(
    $filesArray mysql_fetch_array($filesQuery))
        {
            if(
    $z==0)
            {
                if(!
    ftp_chdir($conn_id $ROOT."/ACT.".md5($WEBSITE)."_stylesheets/")) 
                {
                    
    ftp_mkdir($conn_id$ROOT."/ACT.".md5($WEBSITE)."_stylesheets/");    
                }
            }
            
    $pathFromRoot $filesArray["files"];
            
    $localPathFromRoot "../../users/".md5($WEBSITE)."/".$pathFromRoot;
            
            if(
    file_exists($localPathFromRoot))
            {
                  
    $from fopen($localPathFromRoot'r');
                  if(!
    ftp_fput($conn_id$pathFromRoot$fromFTP_BINARY))
                {
                    
    $x++;
                    die(
    "error uploading"); //added this for testing
                
    }
                
    fclose($from);
            }
            
    $z++;
        }
        
    ftp_close($conn_id);

        if(
    $x==0)
        {
            echo 
    "<span style=\"green\">Files uploaded successfuly!</span>";    
        }
        else
        {
            echo 
    "<span style=\"red\">File upload failed!</span>";
        } 
    this worked fine for about 2 mins then stopped working saying the following

    Code:
    Warning: ftp_fput() [function.ftp-fput]: public_html/e6b4e0d743dbabe2b59eecf807f4b536.txt: Not a directory in /home/sites/snowyswebsolutions.co.uk/public_html/scripts/php/publish.php on line 70
    what i cant understand, public_html/e6b4e0d743dbabe2b59eecf807f4b536.txt being $pathFromRoot, why it returns true for file_exists but says it doesn't with ftp_fput?

    Any ideas?
    Last edited by Phil Jackson; 10-16-2009 at 10:00 AM.
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    it's ok, came too soon again.
    PHP Code:
    if(!ftp_fput($conn_id$pathFromRoot$fromFTP_BINARY)) 
    to
    if(!ftp_fput($conn_id"/".$pathFromRoot$fromFTP_BINARY)) 
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •