Learning purpose: learn to use PHP upload files and emails
Upload file form must be added to ENCTYPE = "Multipart / Form-Data"
And
Let's take a look at the code:
$ f = & $ http_post_files ['file']; $ dest_dir = 'uploads'; // Set upload directory $ dest = $ dest_dir. '/'. Date ("ymd"). "_"). " Name ']; // I set the file name here plus the file name to avoid repeating $ r = move_uploaded_file ($ F [' TMP_NAME '], $ DEST); ChMOD ($ DEST, 0755); // Set upload File properties
Uploaded file named Date ("YMD"). "_"). You can use it when you insert into the database later, PHP is actually moved from the file from the temporary directory to the specified file. table of Contents. Move_uploaded_file ($ F ['TMP_NAME'], $ DEST); this is the key
As for the email, it is simpler, you can use the mail () function
Mail ("Recipient Address", "Subject", "Text", "From: Sender / R / Nreply-to: Sender Address");
However, mail () requires the server's support, and the SMTP server needs to be configured under Windows, generally in the outer Linux space. It seems that uploading files and emails are much simpler than ASP, as long as the function is called. The ASP also needs to use different components of the server such as FSO, Jmail what is.
Ten days learned PHP to say this, my three series of articles used "Ten Days Society" as a name, I want to tell you that ASP, PHP, and ASP.NET can be ten days, but the proficiency is not ten days. Ah, you still need to go to study himself.