Objective: to use PHP to upload files and send emails to upload files, you must add enctype = multipart/form-data and inputtype = filename = file to view the code below: $ f = $ HTTP_POST_FILES ['file']; $ dest_dir = 'uploads'; // Set the upload directory $ dest =
Objective: to learn how to use PHP to upload files and send emails
Enctype = "multipart/form-data" must be added to the file upload form"
And
Let's take a look at the code: $ f = & $ HTTP_POST_FILES ['file'];
$ Dest_dir = 'uploads'; // sets the upload directory.
$ Dest = $ dest_dir. '/'. date ("ymd "). "_". $ f ['name']; // Here I set the file name to date plus the file name to avoid duplication.
$ R = move_uploaded_file ($ f ['tmp _ name'], $ dest );
Chmod ($ dest, 0755); // Set the object name to date ("ymd "). "_". $ f ['name'] can be used later when it is inserted into the database. PHP actually moves the files you uploaded from the temporary directory to the specified directory. Move_uploaded_file ($ f ['tmp _ name'], $ dest); this is the key. it is easier to send emails. you can use the mail () function mail ("recipient address ", "topic", "body", "From: sender \ r \ nReply-to: sender's address"); however, mail () requires support From the server, in WINDOWS, you also need to configure the SMTP server. Generally, the external LINUX space will work. It seems that uploading files and sending emails are much simpler than ASP. you only need to call the function. ASP also needs to use different server components such as FSO and JMAIL. I have learned PHP for ten days. my three series of articles use "ten days of study" as their names. I want to tell you ASP, PHP, and ASP. NET can be started for ten days, but proficient is by no means ten days. you need to study it on your own.