PHP (hypertext Preprocessor) is an HTML-embedded language (similar to ASP on IIS). PHP's unique syntax mixes C, Java, Perl, and PHP-style new syntax. It can perform dynamic Web pages more quickly than CGI or Perl. In addition, the Web back-end CGI program written in PHP can be easily ported to different system platforms.
When we make the website, we need the visitor's participation in order to make the website more compelling, which requires us to get articles, pictures, etc. from the visitor. As a result, file uploads are an essential feature of Web pages. Now I take advantage of the popular programming language PHP, two ways to illustrate the implementation of its functions.
First, the use of PHP file functions to implement the upload
This code is divided into two files, one for upload.html and one for upload.php.
Upload file selection: The upload.html code is as follows:
<title>Uploading a file form</title>
Description * * *
1. Please note
To process the upload file: The ftp.php code is as follows:
FTP Join host functions
Function Connect ()
{
Global $server, $username, $password;
$conn = Ftp_connect ($server);
Ftp_login ($conn, $username, $password);
return $conn;
}
Creating an FTP connection
$result = connect ();
if ($action = = "Upload")
{
Used to change the FTP path
Ftp_chdir ($result, $cdir);
Used to upload the specified file with the same name and passed as Bits
$res _code = Ftp_put ($result, $upfile _name, $upfile, ftp_binary);
Determine if the upload is correct
if ($res _code = = 1)
echo "Upload succeeded!";
Else
echo "Upload error!";
}
Close Join
Ftp_quit ($result);
?>
Description * * *
function ftp_put (int ftp_stream, string remote_file, string local_file, int mode) usage
Return Value: Boolean value
This function is used to upload the specified file. The Ftp_stream parameter is the FTP connection code. The parameter remote_file is the file name to which the remote is to exist. The parameter local_file is the file name of the file to be uploaded. The value of the parameter mode is FTP_ASCII and Ftp_binary two, which represents the document or binary file respectively. Success returns a true value, and a value of false if it fails.
http://www.bkjia.com/PHPjc/314237.html www.bkjia.com true http://www.bkjia.com/PHPjc/314237.html techarticle PHP (hypertext Preprocessor) is an HTML-embedded language (similar to ASP on IIS). PHP's unique syntax mixes C, Java, Perl, and PHP-style new syntax. It can be more than CGI or ...