Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Programmatically upload an image to the media gallery WordPress


Hi all,

I want a custom page template that allows logged in users to add an image to the media gallery. I want the thumbnails to be created automatically. I don't want the user to have to go through the admin interface to do this, hence using a page template. The front end should consist only of a file upload field and an Upload button.


Answers (2)


Francisco Javier Carazo Gil answers:

Have you tried this?

Francisco Javier Carazo Gil comments:

Maybe this is better for your requirement:

Sean H comments:

wow, thank you for this Francisco. I think this what I wanted. testing now. how did you find it? I have been searching for days for this. all of my efforts pointed to this page: - I copied the code, modified it and it didn't work.

Francisco Javier Carazo Gil comments:

Many days searching for WordPress fixes and patches :)

wp_insert_attachment should also work, try with WP_DEBUG to true, let's see whether there is something more.


Kyle answers:

Do you have gravity forms?