
一、单文件上传
<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();
}
}
}
上传两张图片
