WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Upload Via FTP - an alternative to move_uploaded_file
Categories : PHP, FTP, Beginner Guides
Moiz Sitabkhan
Date : May 24th 2007
Grade : 5 of 5 (graded 1 times)
Viewed : 2018
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Moiz Sitabkhan
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

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
Find the day of the week for any given year/month/day.
Categories : PHP, Date Time, Data Validation, Algorithms, Beginner Guides
PHP and javascript mouseover, mouseout, and mousedown events
Categories : PHP, Java Script, Form Processing, Beginner Guides
How to preset a text string in a textarea input field
Categories : HTML, HTML and PHP, PHP, Beginner Guides
Easy alert box pop-up function
Categories : PHP, Java Script, Beginner Guides
Newbie Notes #1 - Making a form return to itself
Categories : PHP, Beginner Guides, HTML and PHP
WebFTP: This tool can be used to access FTP sites from behind any firewall or proxy.
Categories : PHP, FTP
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
mySQL/PHP/search with multientry form and table output with colored rows
Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases
Find if a year is leap.
Categories : PHP, Date Time, Beginner Guides, Data Validation
Introduction to Language Files
Categories : PHP, Filesystem, Beginner Guides
How to Insert a Date Format Into MySQL from PHP
Categories : PHP, Databases, MySQL, Date Time, Beginner Guides
Newbie Notes #10 - Generating drop downs
Categories : PHP, MySQL, HTML, Beginner Guides, Databases
session out Timer
Categories : PHP, Sessions, Security, Beginner Guides
a PHP Function to Get only the filename (remove the extension) using regular expressions.
Categories : PHP, Regexps, Beginner Guides