我有HTML表单:
<form id="add_user_info" enctype="multipart/form-data" method="POST">
<div class="multi_photos multi1">
<input type="file" name="user_passport_photo[]" placeholder="Add Photo">
<input type="file" name="user_passport_photo[]" placeholder="Add Photo">
</div>
<div class="multi_photos multi2">
<input type="file" name="user_voditel_prava[]" placeholder="Add photo">
<input type="file" name="user_voditel_prava[]" placeholder="Add photo">
</div>
<button type="submit" name="add_driver_by_editor" class="btn add_user_info">Add</button>
</form>
和PHP代码:
$data = $_POST;
if(isset($data['add_driver_by_editor'])) {
$driver_id = $data['user_phone'];
$one_driver_path = 'images/' . $driver_id . '/';
mkdir($one_driver_path . 'passport', 0777, true);
for($i = 0; $i < count($_FILES['user_passport_photo']['name']); $i++) {
$path_tmp = $one_driver_path . '/passport' . '/' . basename($_FILES['user_passport_photo']['name'][$i]);
if( move_uploaded_file($_FILES['user_passport_photo']['tmp_name'][$i], $path_tmp) ) {
$driver->driver_passport = 'images/' . $driver_id . '/' . 'passport/';
} else {
echo "Error";
}
}
for($i = 0; $i < count($_FILES['user_voditel_prava']['name']); $i++) {
(LINE 57) $path_tmp = $one_driver_path . '/voditel_prava' . '/' . basename($_FILES['user_voditel_prava']['name'][$i]);
(LINE 58) if( move_uploaded_file($_FILES['user_voditel_prava']['tmp_name'][$i], $path_tmp) ) {
$driver->driver_prava= 'images/' . $driver_id . '/' . 'passport/';
} else {
echo "Error";
}
}
}
当我将几个文件上传到每个&#34; user_passport_photo []&#34;和&#34; user_voditel_right []&#34;,第一个脚本工作正常,但第二个脚本(相同)不起作用。给出错误消息:
第57和58行