Upload Multiple Files With media_handle_upload


I have a WordPress form plugin and I use media_handle_upload to upload the files and get there ids directly and attached its ids to the post as a meta date, I used the following to did that:

The HTML of the form field is:

<input type="file" name="my_file_upload" id="my_file_upload">

And the php code was:

$attach_id = media_handle_upload( 'my_file_upload', $post_id );
if ( is_numeric( $attach_id ) ) {
    update_post_meta( $post_id, '_my_file_upload', $attach_id );

And everything was work perfectly.

Now I am trying to upload multiple files my HTML code is:

<input type="file" name="my_file_upload[]" id="my_file_upload[]" multiple="multiple">

But I cant make the media_handle_upload function work with multiple files upload.

Any help will be appreciated.

, , , , Engr.MTH 11 months 0 Answers 86 views 0

Leave an answer