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