php实现表单提交上传文件功能
本文实例为大家分享了php实现表单提交上传文件功能的具体代码,供大家参考,具体内容如下
首先创建含表单的html文件: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>
再创建服务端文件: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'>"; ?> </body> </html>
点击提交后呈现出文件:
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23