$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>media library - Upload Multiple Files With Multiple Fields And With media_handle_upload|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

media library - Upload Multiple Files With Multiple Fields And With media_handle_upload

matteradmin10PV0评论

I asked this question about few days ago and the answer solved my instantly problem but now when I tried to put many file fields in the form just the first field work because the solution of my previous question overwrite the $_FILES array.

Now I have the following HTML in my form:

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

How can upload these files using media_handle_upload?

Any help will be appreciated.

I asked this question about few days ago and the answer solved my instantly problem but now when I tried to put many file fields in the form just the first field work because the solution of my previous question overwrite the $_FILES array.

Now I have the following HTML in my form:

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

How can upload these files using media_handle_upload?

Any help will be appreciated.

Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked Dec 28, 2014 at 7:41 Engr.MTHEngr.MTH 2731 gold badge2 silver badges7 bronze badges 2
  • Try to remove the numbers my_file_upload1 to my_file_upload . – Shady M Rasmy Commented Dec 28, 2014 at 14:07
  • No problem I changed the names of the fields. Thank you. – Engr.MTH Commented Dec 28, 2014 at 15:17
Add a comment  | 

2 Answers 2

Reset to default 0

code from my theme adjusted to you

<fieldset class="images">
<input type="file" name="my_file_upload[]" id="my_file_upload[]" multiple="multiple">
</fieldset>
<fieldset class="memes">
<input type="file" name="my_file_upload[]" id="my_file_upload[]" multiple="multiple">
</filedset>

and its working

I found it and its work great for me, I used the solution in this answer to solve my problem but I'll not chose my answer as a correct answer because the solution in that question uses this function media_handle_sideload, even if WordPress codex told that this function work like the media_handle_upload function. but I'll wait until someone give me the answer that used media_handle_upload function.

If no one gave me the answer then I'll select my answer.

Post a comment

comment list (0)

  1. No comments so far