foreach $FILES create post how to
-
I know this is probably super easy and I am overlooking something here.
I have a form on the front-end of our website where users can upload an image via a form and it creates a product in our shop. We are using WordPress and Woocommerce but I felt this question was general enough to ask on here.
Currently everything works fine when uploading one image, How would I make this work for when a user uploads multiple images?
In the form I changed
<input type="file" name="thumbnail" id="thumbnail" />
to
<input type="file" name="thumbnail" id="thumbnail" multiple />
and I thought wrapping the below in something like this would work:if ($_FILES) { foreach ($_FILES as $file => $array) { // do necessary code } }
But it doesn’t.
Here is what I have that creates the post. Im not sure why wrapping it in the foreach $FILES won’t work?
You can view the paste bin here: https://pastebin.com/VvwBAEG5
In short I just need a way for the above code to create the post for each file uploaded, instead of just one file uploaded like it currently does.. Im all out of ideas
- The topic ‘foreach $FILES create post how to’ is closed to new replies.