Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // FTP server details
- $ftpHost = 'ftp.host.com';
- $ftpUsername = 'tutsplanet';
- $ftpPassword = 'xxxxxxx';
- // open an FTP connection
- $connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
- // login to FTP
- if(@ftp_login($connId, $ftpUsername, $ftpPassword)){
- echo "Connected as $ftpUsername@$ftpHost";
- }else{
- echo "Couldn't connect as $ftpUsername";
- }
- // local & server file path
- $localDirFilePath = 'test.php';
- $remoteDirFilePath = 'public_html/test.php';
- // Uploading a file
- if(ftp_put($connId, $remoteDirFilePath, $localDirFilePath, FTP_ASCII)){
- echo "File transfer successful - $localDirFilePath";
- }else{
- echo "There is an error while uploading $remoteDirFilePath";
- }
- // close the FTP connection
- ftp_close($connId);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement