<?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.