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 ,...