I have "browse" button so i can select multiple images for upload, but let suppose i select 3 imgaes for upload and then again click on "browse" button for select another 2 images then last two imgaes uploading instead of all 5 images ( 2 new and 3 previous which i selected) so how can i solve this issue ? I want to upload current selected images and previous selected images together ?
Here is my HTML code:
<input type="file" data-max_length="1000" class="upload__inputfile" name="glow_nu_gallery[]" id="glow_nu_gallery" multiple />
PHP Code:
$uploaddir = wp_upload_dir();
$raw_images = $_FILES['glow_nu_gallery'];
$upload_overrides = array( 'test_form' => false );
$glow_p_photos = [];
for ( $i = 0; $i < count( $raw_images['name'] ); $i++ ) {
$file = $raw_images['name'][$i];
$uploadfile = $uploaddir['path'] . '/' . basename( $file );
move_uploaded_file( $raw_images["tmp_name"][$i] , $uploadfile );
$filename = basename( $uploadfile );
$wp_filetype = wp_check_filetype(basename($filename), null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => preg_replace('/\.[^.]+$/', '', $filename),
'post_content' => '',
'post_status' => 'inherit',
'menu_order' => 1000
);
}