PHP (Hypertext Preprocessor) 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.
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.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.