Learning purpose: learn to upload files and send emails in PHP
Enctype="multipart/form data" must be added to the uploaded file form
And<input type="file" name="file">
Let's take a look at the code:
- $f = $HTTP_ POST_ FILES [ 'file' ];
- $dest_ dir = 'uploads' ;
- $dest = $dest_ dir . '/' . date ( "ymd" ). "_" . $f [ 'name' ];
- $r =move_ uploaded_ file( $f [ 'tmp_ name' ], $dest );
- chmod ( $dest , 0755);
The uploaded file is named date ("ymd") "_".$ F ['name '], which can be inserted into data base PHP actually moves the uploaded files from the temporary directory to the specified directory. move_ uploaded_ file($f['tmp_name'],$dest); This is the key
As for sending emails, it is easier to use the mail() function
Mail ("recipient address"“ theme "," body "," From: sender rnReply to: sender address ");
But mail() needs The server The SMTP server needs to be configured under Windows. Generally speaking, the external LINUX space is OK.
It seems that uploading files is better than sending emails ASP It is much simpler. Just call the function. ASP also needs to use different components of the server, such as FSO and JMAIL.
ASP,PHP,ASP. NET entry can take ten days, but mastery is by no means ten days. You need to study it yourself.