PHP development file upload tutorial project introduction

This course uses the development of "php development upload file" as an example of the course project to explain the ideas of developing "php development upload file"

The functions developed in this tutorial are as follows:

Select the file->Process the file->Judge whether the upload is successful

Create the php file:

文件.png

##Let’s take a look at the flow chart:

流程图.png

html page code is as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文件上传</title>
</head>
<body>
    <form method="post" action="doaction.php" enctype="multipart/form-data">
        上传文件:<input type="file" name="myfile"><br>
                  <input type="submit" value="上传文件">
    </form>
</body>
</html>

Looking at the above code, the form is submitted in post mode and submitted to the doaction.php file

Please note: enctype="multipart/form-data"

This sentence is essential when operating file uploads. enctype="multipart/form-data" means binary data. format to transmit, so it is binary data transmitted to your servlet

Note: There is an error in this sentence, which we may often encounter when we write this code

The following data will be written as date This requires our attention


enctype="multipart/form-data"


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文件上传</title> </head> <body> <form method="post" action="doaction.php" enctype="multipart/form-data"> 上传文件:<input type="file" name="myfile"><br> <input type="submit" value="上传文件"> </form> </body> </html>
submitReset Code