10 days to learn php

Source: Internet
Author: User
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.
 

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.