我有这个代码提交多个文件和标题我试图将结果合并到我的数据库并检查标题 [] 是否为空并打印自定义值但我的标题 [] 有问题我需要与 s_upload 结合[] 大批:
<?php
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ){
foreach ($_FILES["s_upload"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["s_upload"]["tmp_name"][$key];
$name = $_FILES["s_upload"]["name"][$key];
// move_uploaded_file($tmp_name, "data/$name");
if ($_POST['title']==''){
echo 'Title';
}else{
print_r ($_POST['title']);
echo $name;
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<div class='file_upload' id='f1'>
<input type="text" name="title[]" id="t1">
<input size="14" name='s_upload[]' id="i1" type='file'/>
</div>
<div class='file_upload' id='f2'>
<input type="text" name="title[]" id="t2">
<input size="14" name='s_upload[]' id="i2" type='file'/>
</div>
<input type="submit"/>
</form>
</body>
</html>
当我提交这是结果:
Array ( [0] => 11111 [1] => 22222 ) 1.jpgArray ( [0] => 11111 [1] => 22222 ) 2.jpg
如果标题存在,我需要这个结果:
1111 1.jpg
2222 2.jpg
如果标题为空,则结果如下:
Title 1.jpg
2222 2.jpg