Home  >  Article  >  Backend Development  >  Implementation principle of PHP upload and download

Implementation principle of PHP upload and download

Guanhui
GuanhuiOriginal
2020-05-13 14:26:532323browse

Implementation principle of PHP upload and download

The implementation principle of PHP upload and download

First, the user submits the file to the PHP server, and PHP will automatically temporarily store the file; Then the business code saves the file to the server and returns the file access address; finally, the front end accesses and downloads the file based on the access address.

File upload example

HTML:


    
        简单文件上传
    

PHP:

 0){
    echo "错误信息".$_FILES["myfile"]["error"];
} else {
    echo $myfile.'
'; echo $tmp.'
'; echo $size/1024 .'KB
'; echo $type.'
'; echo $error.'
'; } if(file_exists("./".$_FILES["myfile"]["name"])){ echo $_FILES["myfile"]["name"] . " 文件存在"; } else { move_uploaded_file($_FILES['myfile']['tmp_name'],"./". $_FILES["myfile"]["name"]); echo "文件位置:"."./". $_FILES["myfile"]["name"]; }

Recommended tutorial:《PHP Tutorial

The above is the detailed content of Implementation principle of PHP upload and download. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn