In doing picture upload used to symfony third-party upload Library, see Symfony2 use Third-party library upload production picture upload "original", but for many pictures upload how to deal with, here I used a stupid way is to convert multiple images array into a single image array upload!
The form is submitted as follows:
The array of accepted picture information is as follows:
So do some processing of this, a single picture is uploaded in turn, as follows:
If (isset $_files[' image ') && $_files[' image '] [' name ']] {
$file = $_files[' image '];
& nbsp $num = count ($_files[' image '] [' name ']); Calculate the number of uploaded pictures
/processing array
for ($i =0 $i < $num; $i + +) {
$data [$i] [' name '] = $file [ ' Name ' [$i];
$data [$i] [' type '] = $file [' type '] [$i];
$data [$i] [' tmp_name '] = $file [' Tmp_name '] [$i];
$data [$i] [' error '] = $file [' ERROR '] [$i];
$data [$i] [' size '] = $file [' Size '] [$i];
}
foreach ($data as $key => $val) {
$_files[' image ' = $val;
&nb sp; if (move_uploaded_file ($val [' name '], './', $val [' name ']) {
Echo ' ";
}else{
Echo is out of error! ';
}
}
$info [' image '] = serialize ($img); Serializing an array of stored databases
$conn->insert (' Maintenance ', $info);
}
This is a more lazy approach, there are wrong places also look for more advice!
Note: fileupload (' image ') is an upload class, you can refer down to see Move_uploaded_file ($value, $savepath);