PHP File Upload Program Simple example

Source: Internet
Author: User
Tags file upload php file php file upload

More familiar to the ASP friend may know to upload files with ASP but not too simple, PHP is different, easier, see examples: Send.htm and get.php as follows:

<!--文件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 following code receives the uploaded file

<?php
#文件get.php
  if (rename($userfile,"dirupload.dat)") {
    echo "成功!";
    }
  else {
    echo "上传不成功!";
   }
?>

Description

A temporary directory in the php.ini file Upload_tmp_dir used to describe the file placement of PHP uploads

Second, the upload file stored in the temporary directory if not moved or renamed, it will be deleted immediately

Third, upload the file directory to have write permission

Last suggestion: Do not let the user upload executable files, or the settings can not be implemented, we 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.