|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
This is a useful function if you want to transfer files between SERVERS. NOTE : sometimes you wish to transfer files between two servers... or if you have built a CMS and you want ot install the program on a clients server, it is advisable to transfer files by FTP rather than the move_uplaoded_file. This function accepts a parameet -- location of the file
|
<?php
function uploadFileFTP($FileName) {
//connect to the ftp server
$conn_id = ftp_connect(FTP_SERVER_ADDRESS);
// login with username and password
$login_result = ftp_login($conn_id, FTP_USER, FTP_PASSWORD);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo error="FTP connection has failed!<br>Attempted to connect to ".FTP_SERVER." for user : ".FTP_USER;
return false;
}
//skip these two steps if you dont want to change the working directory
ftp_chdir($conn_id, "wwwroot");
ftp_chdir($conn_id, "my_folder");
// upload the file
$upload = ftp_put($conn_id, $FileName, $source_file, FTP_BINARY);
if (!$upload) {
echo error="FTP upload has failed!";
ftp_close($conn_id);
return false;
} else {
ftp_close($conn_id);
return $FileName;
}
}
?> | | |
|
| Check if a file exists on a remote FTP server with PHP Categories : PHP, FTP, Regexps | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance. Categories : HTML, PHP, HTML and PHP, Beginner Guides | | | Basic Authentication with sessions Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions | | | Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support Categories : PHP, FTP, Filesystem, PHP Classes, Compression | | | PHP and javascript mouseover, mouseout, and mousedown events Categories : PHP, Java Script, Form Processing, Beginner Guides | | | Link Submition - Allow your visitors to submit links to the site. Categories : PHP, Arrays, Filesystem, Beginner Guides | | | Simple Session example Categories : PHP, Beginner Guides, Sessions | | | a PHP Function to Get only the filename (remove the extension) using regular expressions. Categories : PHP, Regexps, Beginner Guides | | | for each record, do this to the first record, and do that to any subsequent record Categories : PHP, Databases, MySQL, Beginner Guides | | | Newbie Notes #5 - To double quote, or single quote, that is the question Categories : PHP, Beginner Guides, Variables | | | very simple ftp class Categories : PHP, PHP Classes, FTP | | | Change the background color of a website daily dynamically using the php date function to get the current day of the week and depending on that day, set the background color for the web page. Categories : PHP, Date Time, Beginner Guides, Web Design | | | Convert a File database into MySQL Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides | | | PHP Function for Random Digits Categories : PHP, Beginner Guides | |
|
|