PHP implementation of a good way to upload

zhaozj2021-02-08  222

Online is very free of charge, PHP personal home home is now a lot, sometimes it is going to upload, but after all, it is free, of course, there will be many restrictions, not allowed to upload, this is normal, some even Mail () The function is not used. In this case, it is not a way to upload, PHP supports powerful socket, of course, can not directly operate FTP, look at the function table, and upload it through FTP. Not very good, do we go upload the home page not uploaded with FTP?

The implementation code is as follows:

//upload.php

Upload file:

$ ftp_server = "FTP server (best use IP)"; $ ftp_username = "ftp user name"; $ ftp_password = "login password"; $ ftp_dir = "directory (such as set to /)";

IF ($ ACTION == "OK") {$ con = ftp_connect ($ ftp_server); // Connect FTP FTP_Login ($ con, $ ftp_username, $ ftp_password); // User Login $ SUSS = $ Con; FTP_CHDIR ($ SUSS , $ ftp_dir); // CD to the specified directory

$ ok_code = ftp_put ($ subs, $ upload_file_name, $ upload_file, ftp_binary); // PUT file IF ($ OK_CODE == 1) {echo "file upload success! / n";} else {echo "file upload failed! / n ";} ftp_quit ($ suss); // Turn the FTP connection}

?>

转载请注明原文地址:https://www.9cbs.com/read-2682.html

New Post(0)