troubleshooting Question

save .csv file to a particular directory

Avatar of Zac
ZacFlag for United Kingdom of Great Britain and Northern Ireland asked on
PHPNetworking Protocols
5 Comments1 Solution495 ViewsLast Modified:

the code below is fetching a csv file for me from an FTP account. it works fine except that it totally ignores where i want the csv file to be saved.

where is says 'YOUR FOLDER PATH' i've been putting in here C:inetpub\wwwroot\mydomain\temp

but instead of putting it in the /temp dir it just dropps the csv file in the same dir as from where the script is run from which is a completly different dir.

any ideas?



                // define some variables
        $folder_path = "YOUR FOLDER PATH"; 
        $local_file = "the_file.csv";
        $server_file = "the_file.csv";
        //-- Connection Settings
        $ftp_server = "IP ADDRESS"; // Address of FTP server.
        $ftp_user_name = "USERNAME"; // Username
        $ftp_user_pass = "PASSWORD"; // Password
        #$destination_file = "FILEPATH"; 
        // set up basic connection
        $conn_id = ftp_connect($ftp_server);
        // login with username and password
        $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
        // try to download $server_file and save to $local_file
        if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
            echo "Successfully written to $local_file\n";
        } else {
            echo "There was a problem\n";
        // close the connection
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros