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
2 Answers
Reset to default 0code 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.