Monthly Archives: May 2009

Upload Via FTP – an alternative to move_uploaded_file

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;
}
}
?>

JAVA Coding Standards

Code conventions are important to programmers for a number of reasons:

  • 80% of the lifetime cost of a piece of software goes to maintenance.
  • Hardly any software is maintained for its whole life by the original author.
  • Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.
  • If you ship your source code as a product, you need to make sure it is as well packaged and clean as any other product you create.

We can find a lot of information about the coding standards at the link below.

http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html