我要使用POST方法一次单击上传多张图片。我想在数据库中保存每个图像的路径,但是没有任何内容存储在该本地文件夹路径上。我要从多个输入而不是从单个输入获取多个图像。
输入要上传的文件,然后单击添加以从另一个file_input标签添加另一个。依此类推。
Array ( [0] => Array ( [attachment] => 8.jpg ) [1] => Array ( [attachment] => 3-D80A.JPG ) )
前
<form method="post" action="">
<input type="file" id="file" name="attachment[0][attachment]">
<input type="file" id="file" name="attachment[1][attachment]">
<input type="submit" name="submit_case" value="Save" class="btn btn-primary">
</form>
返回
foreach (array_keys($_FILES["attachment"]["name"]) as $fieldKeysymtoms) {
foreach ($_FILES["attachment"]["name"][$fieldKeysymtoms] as $key=>$value) {
print_r($_FILES["attachment"]["name"][$fieldKeysymtoms]);
if(move_uploaded_file($_FILES["attachment"]["tmp_name"][$fieldKeysymtoms], "app-assets/images/".$name)){
$uploads = "app-assets/images/".$name;
}
$json_symtoms_array+=array($fieldKeysymtoms => $value);
}
}