Use PHP to upload files. PHP (HypertextPreprocessor) is an embedded HTML language (similar to ASP on IIS ). The unique PHP syntax is a mixture of new C, Java, Perl, and PHP syntaxes. It can be equivalent to CGI or PHP (Hypertext Preprocessor), which is an embedded HTML language (similar to ASP on IIS ). The unique PHP syntax is a mixture of new C, Java, Perl, and PHP syntaxes. It can execute dynamic web pages more quickly than CGI or Perl. In addition, the Web backend CGI program written in PHP can be easily transplanted to different system platforms.
When creating a website, we need the visitor's participation to make the website more eye-catching. This requires us to get articles and images from the visitor. Therefore, file upload is an essential feature in web pages. Now I will use the popular programming language PHP to describe its function implementation in two ways.
I. use php file functions for Upload
This code is divided into two files, one is upload.html and the other is upload. php.
Select Upload File: upload.html code:
Upload file Form
* ** Description ***
1. Please note
Process uploaded files: The ftp. php code is as follows:
// Ftp host connection function
Function connect ()
{
Global $ server, $ username, $ password;
$ Conn = ftp_connect ($ server );
Ftp_login ($ conn, $ username, $ password );
Return $ conn;
}
// Create an ftp connection
$ Result = connect ();
If ($ action = "upload ")
{
// Used to change the ftp path
Ftp_chdir ($ result, $ cdir );
// Used to upload the specified object, which has the same name and is passed in binary.
$ Res_code = ftp_put ($ result, $ upfile_name, $ upfile, FTP_BINARY );
// Determine whether the upload is correct
If ($ res_code = 1)
Echo "Upload successful! ";
Else
Echo "upload error! ";
}
// Close the connection
Ftp_quit ($ result );
?>
* ** Description ***
Function ftp_put (int ftp_stream, string remote_file, string local_file, int mode) usage
Return value: Boolean
This function is used to upload a specified object. The ftp_stream parameter is the FTP connection code. The remote_file parameter is the name of the target remote object. The local_file parameter is the name of the file to be uploaded. The mode parameter has two types of values: FTP_ASCII and FTP_BINARY, indicating the document or binary file respectively. If the call succeeds, the return value is true. if the call fails, the return value is false.
Hypertext Preprocessor is an HTML embedded language (like ASP on IIS ). The unique PHP syntax is a mixture of new C, Java, Perl, and PHP syntaxes. It can be worse than CGI or...