zoukankan      html  css  js  c++  java
  • php upload

    <?php
    
    /**
     * @Author: cyany_blue
     * @Date:   2018-11-24 15:24:31
     * @Last Modified by:   cyany_blue
     * @Last Modified time: 2018-11-24 15:53:47
     */
    if(isset($_FILES['img'])){
    	$img_name = $_FILES["img"]["name"];
    	$img_size = $_FILES["img"]["size"];
    	$img_temFile = $_FILES["img"]["tmp_name"];
    	$img_type = $_FILES["img"]['type'];
    	echo $img_name."<br>";
    	echo $img_size."<br>";
    	echo $img_temFile."<br>";
    	echo $img_type."<br>";
    	move_uploaded_file($img_temFile, 'img/'.$img_name);   //Note:two arguments,first is file needed to move , second is  file moved to .
    	echo "ok !";
    
    }
    
    ?>
    <form action="" method="post" enctype="multipart/form-data">
    	<input type="file" name="img" />
    	<input type="submit" value="submit">
    </form>
    

    upload multiple

    you should add multiple to input element
    and change name="img[]";
    like it:

    <form action="" method="post" enctype="multipart/form-data">
    	<input type="file" name="img[]" />
    	<input type="submit" value="submit">
    </form>
    

    and run it , you will get it:

    array (size=1)
      'img' => 
        array (size=5)
          'name' => 
            array (size=2)
              0 => string '360截图20180916201047398.jpg' (length=30)
              1 => string '360截图20181025200949887.jpg' (length=30)
          'type' => 
            array (size=2)
              0 => string 'image/jpeg' (length=10)
              1 => string 'image/jpeg' (length=10)
          'tmp_name' => 
            array (size=2)
              0 => string 'E:wamp64	mpphpD36A.tmp' (length=25)
              1 => string 'E:wamp64	mpphpD37B.tmp' (length=25)
          'error' => 
            array (size=2)
              0 => int 0
              1 => int 0
          'size' => 
            array (size=2)
              0 => int 40554
              1 => int 30763
    


    Haha,that is all.

  • 相关阅读:
    Func<>委托、扩展方法、yield、linq ForEach综合运用
    EntityFramework学习要点记一
    MVC模型验证
    MVC过滤器
    解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突
    Linq操作之Except,Distinct,Left Join 【转】
    WebClient小结
    Code First项目Migrations
    jquery之on()绑定事件和off()解除绑定事件
    Bootstrap页面响应式设计
  • 原文地址:https://www.cnblogs.com/cyany/p/10012445.html
Copyright © 2011-2022 走看看