php的表单提交之上传文件
2015-08-28 14:33
706 查看
首先创建含表单的html文件:upload.html
再创建服务端文件:upload.php
<!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>点击提交后呈现出文件:
相关文章推荐
- laravel的解决方案
- php内容嵌入html
- Laravel 4 系列入门教程(一)
- PHP 的 抽象类 abstract 和 接口 interface
- Yii GridView Ajax 刷新
- laravel 分页
- php错误:You don't have permission to access / on this server.
- php的一些心得
- PHP下拉框内容随单选框内容变化
- 一个简单的PHP在线书签系统
- php.ini中时区设置不成功解决方法
- thinkphp U方法 跨入口生成连接
- PHP trigger_error() 函数
- PHP date 格式化一个本地时间/日期
- PHP文本框的值随下拉框改变
- php 三元运算符使用说明和写法
- busybox自带的FTP服务器
- windows下使用curl下载ftp文件(ftp有密码)
- php匿名函数
- 八月,整理一些无聊的资料,以便无聊的时候看