Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //ftp server information
- //change values to reflect you server settings
- $ftp_server = "ftp.yoursite.com";
- $ftp_username = "username";
- $ftp_password = "password";
- $server_file = "/path_to_csv_file/inventory.csv";
- $local_file = "inventory.csv";
- //connect to ftp server
- $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
- $login = ftp_login($ftp_conn, $ftp_username, $ftp_password);
- //download the csv file to local folder
- if (ftp_get($ftp_conn, $local_file, $server_file, FTP_ASCII)) {
- //load the contents of downloaded csv file
- $file_contents = file_get_contents($local_file);
- } else {
- //set an error message if ftp_get fails
- $file_contents = "Error downloading $server_file.";
- }
- //close ftp connection
- ftp_close($ftp_conn);
- //send the contents of the csv file (or the error message) to standard output
- header('Content-Type: text/plain');
- echo $file_contents;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement