zoukankan      html  css  js  c++  java
  • 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();
    		}
    	}
    	
    }
    

     上传两张图片

  • 相关阅读:
    mysql字符集设置
    mysql解压版服务启动方式
    html的表格边框为什么会这么粗?
    通过js获取tinymce4.x的值
    bzoj 3083 树链剖分
    bzoj 1143 二分图最大独立集
    bzoj 2303 并查集
    可持久化数据结构讲解
    bzoj 1072 状压DP
    bzoj 2741 可持久化trie
  • 原文地址:https://www.cnblogs.com/navyouth/p/8596034.html
Copyright © 2011-2022 走看看