SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    create file and ftp question

    I am trying to create a file and ftp it to a server. It creates fine, but it has a problem ftping it, almost like ti can not find the file, until the next time I run the script, and then it finds it. Anyway, any help would be appreciated. Here is the code snippet:

    PHP Code:

    $text
    "some text";

    $xmlfile $directory .'DONE' .$file;
                        
    $fh fopen($xmlfile'w+') or die("can't open file");
                        
    fwrite ($fh$text);
                        
    fclose($fh);
                      

                         
    //* Start FTP of new file

    $ftp_server="ftp.domain.com";
    $ftp_user="ftpuser";
    $ftp_pass="password";

    $fp=fopen($xmlfile,"r");

    $conn_id ftp_connect($ftp_server) or die("Could not connect");

    ftp_login($conn_id$ftp_user$ftp_pass);

    if (
    ftp_fput($conn_id$xmlfile$fpFTP_ASCII)) {
        echo 
    "Successfully uploaded $xmlfile\n";
    } else {
        echo 
    "There was a problem while uploading $xmlfile\n";
    }

    // close the connection and the file handler
    ftp_close($conn_id);
                     
    //  END FTP //     

                         
    fclose($fp); 

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out.


Bookmarks

Posting Permissions

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