10 days to learn php

Source: Internet
Author: User

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.

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.