码迷,mamicode.com
首页 > Web开发 > 详细

TP文件上传

时间:2018-03-18 17:17:50      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:AC   art   this   分享   space   type   pre   技术分享   mit   

技术分享图片

一、单文件上传

<form action="__ACTION__" enctype="multipart/form-data" method="post" >
	<input type="text" name="name" />
	<input type="file" name="photo" />
	<input type="submit" value="提交" >
</form>

 技术分享图片

<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller{
	public function login(){
		if(!empty($_POST)){
			
			$upd = new \Think\Upload();
			$upd->rootPath = "./Public/";
			$upd->savePath = "./upload/";
			$info = $upd->upload();
			
			
		}else{
			$this->show();
		}
	}
	
}

提交以后文件里多了一个文件夹

 技术分享图片

二、多文件上传

<form action="__ACTION__" enctype="multipart/form-data" method="post" >
	<input type="text" name="name" />
	<input type="file" name="photo" />
	<input type="file" name="photo1" />
	<input type="submit" value="提交" >
</form>

 技术分享图片

<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller{
	public function login(){
		if(!empty($_POST)){
			
			$upd = new \Think\Upload();
			$upd->rootPath = "./Public/";
			$upd->savePath = "./upload/";
			$info = $upd->upload();
			var_dump($info);
			
			
		}else{
			$this->show();
		}
	}
	
}

 上传两张图片

技术分享图片

 

TP文件上传

标签:AC   art   this   分享   space   type   pre   技术分享   mit   

原文地址:https://www.cnblogs.com/navyouth/p/8596034.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!