Home >Backend Development >PHP Tutorial >PHP form submission to upload files
First create the html file containing the form: upload.html
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>上传文件</title> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="file"/> <input type="submit" value="提交"> </form> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>显示文件</title> </head> <body> <?php //print_r($_FILES); //获取到临时文件 $file=$_FILES['file']; //获取文件名 $fileName=$file['name']; //移动文件到当前目录 move_uploaded_file($file['tmp_name'],$fileName); //显示文件 echo "<img src='$fileName'>"; ?> </body> </html>clicks submit and the file is displayed:
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces PHP form submission and uploading files, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.