PHP: a good way to upload files _ PHP Tutorial

Source: Internet
Author: User
PHP is a good way to upload files. P there are a lot of personal homepage spaces that support PHP for free on the internet. at this time, I may think of uploading something. but after all, it is free, and of course there are many restrictions, so I cannot upload it, p> There are a lot of personal homepage spaces that support PHP for free on the Internet. at this time, you may think of uploading something. However, after all, it is free of charge. Of course there are many restrictions and it is not allowed to upload, this is normal, and some do not even use the Mail () function. In this case, there is no way to upload files. PHP supports powerful sockets and, of course, ftp operations are indispensable. check the function table and use ftp to upload files. Not very good. didn't we use ftp to upload the home page.
The implementation code is as follows:
// Upload. php



$ Ftp_server = "ftp server (preferably IP )";
$ Ftp_username = "ftp username ";
$ Ftp_password = "logon password ";
$ Ftp_dir = "directory (for example, set /)";
If ($ action = "OK ")
{
$ Con = ftp_connect ($ ftp_server); // Connect to ftp
Ftp_login ($ con, $ ftp_username, $ ftp_password); // user logon
$ Suss = $ con;
Ftp_chdir ($ suss, $ ftp_dir); // cd to the specified directory
$ OK _code = ftp_put ($ suss, $ upload_file_name, $ upload_file, FTP_BINARY); // put file

If ($ OK _code = 1)
{
Echo "file uploaded successfully! ";
}
Else
{
Echo "file Upload failed! ";
}
Ftp_quit ($ suss); // Close the ftp connection
}
?>




Http://www.bkjia.com/PHPjc/445194.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445194.htmlTechArticleP online very free support PHP personal home page space now a lot, then may think of a Upload or something, but after all belong to the free, of course, there are a lot of restrictions, upload not allowed ,...

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.