How to implement form submission in php, the specific steps are as follows:
First create an html file containing the form: upload.html
<!DOCTYPE html> <html> <head> <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>
Related recommendations: "php Getting Started Tutorial"
Create the server file: upload.php
<!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' alt="How to implement form submission in php" >"; ?> </body> </html>
Click submit and the file will be displayed:
The above is the detailed content of How to implement form submission in php. For more information, please follow other related articles on the PHP Chinese website!