Results 1 to 2 of 2

Thread: Uploading files on server

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Uploading files on server

    Still i am unable to uplod file on server. Please have look code bleow

    PHP Code:
    <?
    ////////////Following Script Dowloads contents from Phonocat FTP Server Respective folders///////////////////////
        set_time_limit(0);
        // Videoservicesftp server connection variables

        $ftp_server = "######";
         $conn_id = ftp_connect($ftp_server) or die("Unable to connect to the server");
        $ftp_user_name = "####";
        $ftp_user_pass = "####";
        //////////////////////////////////////////////////////////LOGIN WITH USER AND PASSWORD//////////////////////////////////////////////
        // login with username and password
        $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

        ////////////////////////////////CHECHK FTP CONNECTION ////////////////////////////////////////////////////////////////////////

        // check connection
        if ((!$conn_id) || (!$login_result)) {
               echo "FTP connection has failed!";
               echo "Attempted to connect to $ftp_server for user $ftp_user_name";
               exit;
            } else {
             echo "Connected to $ftp_server, for user $ftp_user_name";
           }
           
           /////////////////////////// GET FTP DIRECTORY /////////////////////////////////////////////////////////////////////////////
        ftp_pasv($conn_id, true);
            if (ftp_chdir($conn_id, "pub2")) { 
        echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
        } else { 
        echo "Couldn't change directory\n";
        }
        echo "<br>";
        //echo $curdir = ftp_pwd($conn_id); 

    // file to upload:

    $local_file = glob("D:/nusphere/apache/htdocs/Msafe/VSN/order/*.txt"); 

    // perform file upload
    for($i=0;$i<count($local_file);$i++);

    $upload = ftp_put($conn_id, $curdir, $local_file[$i], FTP_BINARY);
     
    // check upload status
    if (!$upload)
    echo "FTP upload has failed!";
    else
    echo "Uploaded successful...........";

    // close the FTP stream
    ftp_close($conn_id);
    ?>
    Regards
    Ramesh
    Last edited by penagate; Apr 24th, 2007 at 01:56 AM. Reason: Added [php] tags

Posting Permissions

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



Click Here to Expand Forum to Full Width