Objective: To Learn How to Use PHP to upload files and send emails
Enctype = "multipart/form-data" must be added to the file upload form"
And <input type = "file" name = "file">
Let's take a look at the code below:
$ F = & $ HTTP_POST_FILES ['file'];
$ Dest_dir = 'uploads'; // sets the upload directory.
$ Dest = $ dest_dir. '/'. date ("ymd "). "_". $ f ['name']; // here I set the file name to date plus the file name to avoid duplication.
$ R = move_uploaded_file ($ f ['tmp _ name'], $ dest );
Chmod ($ dest, 0755); // sets the attributes of the uploaded file
The uploaded file name is date ("ymd "). "_". $ f ['name'] can be used later when it is inserted into the database. PHP actually moves the files you uploaded from the temporary directory to the specified directory. Move_uploaded_file ($ f ['tmp _ name'], $ dest );
Mail is simpler. You can use the mail () function.
Mail ("recipient address", "topic", "body", "From: sender \ r \ nReply-to: sender address ");
However, mail () requires the support of the server. In WINDOWS, you also need to configure the SMTP server. Generally, the LINUX space outside will work.
It seems that uploading files and sending emails are much simpler than ASP. You only need to call the function. ASP also needs to use different server components such as FSO and JMAIL.
I have learned PHP for ten days. My three series of articles use "ten days of Study" as their names. I want to tell you ASP, PHP, and ASP. NET can be started for ten days, but proficient is by no means ten days. You need to study it on your own.