Learning purpose: Learn to use PHP to upload files and send emails
The upload file form must add enctype="multipart/form-data"
and
Look at the code below:
$f=&$HTTP_POST_FILES['file'];
$dest_dir='uploads';//Set the upload directory
$ dest=$dest_dir.'/'.date("ymd")."_".$f['name'];//I set the file name here with the date plus the file name to avoid duplication
$r=move_uploaded_file ($f['tmp_name'],$dest);
chmod($dest, 0755);//Set the attributes of the uploaded file
The name of the uploaded file is date("ymd") ."_".$f['name'] can be used when inserting into the database later. PHP actually moves the file you uploaded 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 even simpler. You can use the mail() function
mail("recipient address" ,"Subject","Text","From: sender rnReply-to: sender's address");
However, mail() requires server support, and SMTP server needs to be configured under WINDOWS , Generally speaking, any external LINUX space will work.
It seems that uploading files and sending emails is much simpler than ASP. You only need to call functions. ASP also needs to use different components of the server such as FSO, JMAIL and so on.
That’s it for learning PHP in ten days. My three major series of articles all use “Learning in Ten Days” as their names. What I want to tell you is that getting started with ASP, PHP, and ASP.NET can all take ten days. But mastery is by no means ten days, and everyone still needs to study it by themselves.