File Upload implementation

Source: Internet
Author: User

File Upload implementation

If you are familiar with ASP, you may know that it is not easy to upload files using ASP. php is different and easier. For example, send.htm and get. php are as follows:

<! --File send.htm -->
<Form enctype = "multipart/form-Data" Action = "Get. php" method = post>
<Input type = "hidden" name = "max_file_size" value = "1000">
Send this file: <input name = "userfile" type = "file">
<Input type = "Submit" value = "Send File">
</Form>

The followingCodeReceive uploaded files
<? PHP
# File get. php
If (Rename ($ userfile, "\ dir \ upload. dat )"){
Echo "successful! ";
}
Else {
Echo "Upload Failed! ";
}
?>

Note:
I. The upload_tmp_dir file in the PHP. ini file is used to describe the temporary directory of the files uploaded by PHP.
2. If the uploaded files stored in the temporary directory are not moved or renamed, they will be deleted immediately.
3. You must have the write permission on the directory for uploading files.
Last suggestion: Do not allow users to upload executable files, or set the file to be unexecutable. You should know why

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.