How to learn PHP day in 10 days

Source: Internet
Author: User
Tags date learn php mail
Learning Purpose: Learn to upload files and email in PHP

Upload file form must add Enctype= "Multipart/form-data"

Let's take a look at the code:

$f =& $HTTP _post_files[' file '];
$dest _dir= ' uploads '/set upload directory
$dest = $dest _dir. '/'. Date ("Ymd"). " _ ". $f [' name '];//me here Set file name to date plus filename to avoid duplication
$r =move_uploaded_file ($f [' Tmp_name '], $dest);
chmod ($dest, 0755);//Set the properties of the uploaded file

The uploaded file name is date ("Ymd"). _ ". $f [' name '], which can be used later when inserting into the database, PHP actually moves the file you uploaded from the temporary directory to the specified directory. Move_uploaded_file ($f [' Tmp_name '], $dest); That's the key.

It's easier to send mail, you can use the mail () function

Mail ("Recipient address", "subject", "Body", "From: Sender \r\nreply-t address");

However, mail () requires the support of the server, in Windows also need to configure the SMTP server, generally outside the Linux space is OK.

It seems that uploading files and sending emails is much simpler than ASP, as long as you call a function. ASP also needs to use different components of the server such as FSO, JMail and so on.

10 days Learn PHP said here, PHP can be 10 days, but proficient in no more than 10 days ah, but also need everyone to study themselves.

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