Replies: 3
Hi there,
I have a working function that create a new post upon submitting a form. I had to add an upload field to this form to let people upload an image that tend to become the post featured image. I’ve tried a lot of things but it seems that I cannot achieve it for now.
What I’d like to know is how can I get the uploaded file id from my website’s library? I think that if I could get the id I could siply use set_post_thumbnail()
function to update my post.
I’ve tried $_POST['upload-1']['id'];
where upload-1
is the name of my field in the form but I have an error Undefined index: upload-1
in my logs. What is the right way to get the ID of the uploaded image please?