10 days Learn PHP day _php Tutorial

Source: Internet
Author: User
Tags learn php
Learning Purpose: Learn to upload files and send emails in PHP

Upload file form must be added enctype= "Multipart/form-data"
And
Here's 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 file name 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 a database, PHP is actually moving your uploaded files from the temporary directory to the specified directory. Move_uploaded_file ($f [' Tmp_name '], $dest); This is the key.

As for sending e-mail, it is easier to use the mail () function

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

However, mail () requires the support of the server, under 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 the functions are called. The ASP also needs to use the different components of the server, such as FSO, JMail, etc.

10 days to learn PHP said here, my three series of articles are used "Ten days to learn" as the name, want to tell everyone is asp,php,asp. NET entry can be 10 days, but mastery is never 10 days ah, but also needs to be researched by everyone.

http://www.bkjia.com/PHPjc/314895.html www.bkjia.com true http://www.bkjia.com/PHPjc/314895.html techarticle Learning Purpose: Learn to upload files with PHP and send e-mail upload file form must be added enctype= "multipart/form-data" and input type= "file" name= "file" Look at the code: $f = $des ...

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