TP文件上传

一、单文件上传

<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 HomeController;
use ThinkController;
class LoginController extends Controller{
	public function login(){
		if(!empty($_POST)){
			
			$upd = new ThinkUpload();
			$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 HomeController;
use ThinkController;
class LoginController extends Controller{
	public function login(){
		if(!empty($_POST)){
			
			$upd = new ThinkUpload();
			$upd->rootPath = "./Public/";
			$upd->savePath = "./upload/";
			$info = $upd->upload();
			var_dump($info);
			
			
		}else{
			$this->show();
		}
	}
	
}

 上传两张图片

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