0

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.

  • Try to remove the numbers my_file_upload1 to my_file_upload . – Shady M Rasmy Dec 28 '14 at 14:07
  • No problem I changed the names of the fields. Thank you. – Engr.MTH Dec 28 '14 at 15:17
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

| improve this answer | |
  • Thank you for your answer but I have many fields that doesn't contain [] at the end of their names for example the featured image field and in another form the avatar image field and with different names. – Engr.MTH Dec 28 '14 at 19:39
  • did you try it and didnt work ? – Shady M Rasmy Dec 28 '14 at 19:43
  • Yes with different names and in my case I test it and it didn't work :( – Engr.MTH Dec 29 '14 at 7:41
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.