我想一次在php中上传多个图像,但是图像没有移动到该文件夹,并且phpmyadmin中的media_image列仍然为空
<form action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="post_status">ALBUM</label>
<select name="media_post_id" id="">
<?php show_albums_add_media_page(); ?>
</select>
</div>
<div class="form-group">
<label for="post_image">Post Image</label>
<input name="file[]" type="file" multiple="multiple" />
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" name="create_media" value="Publish Media">
</div>
</form>
function add_media(){
if(isset($_POST['create_media'])) {
$media_post_id = escape_string($_POST['media_post_id']);
foreach ($_FILES['file']['tmp_name'] as $index => $tmpName) {
if( !empty( $tmpName ) && is_uploaded_file( $tmpName ) )
{
$post_image = escape_string($_FILES['file']['name']);
$post_image_temp = escape_string($_FILES['file']['tmp_name']);
move_uploaded_file($post_image_temp, "../images/$post_image" );
$query = query("INSERT INTO mediatar(media_image,media_post_id) VALUES('{$post_image}','{$media_post_id}') ");
confirm($query);
}
}
set_message("<h4 class='bg-success'>New medias have been added!</h4>");
redirect("index.php?media");
}
}