I'm building my own WordPress plugin and I have a form where I put in some data. In addition, every entry has an image. Does anybody know how I can upload an image using the WordPress media selector?
I'm building my own WordPress plugin and I have a form where I put in some data. In addition, every entry has an image. Does anybody know how I can upload an image using the WordPress media selector?
Share Improve this question asked Mar 12, 2019 at 17:23 EllyElly 32 bronze badges1 Answer
Reset to default 0https://codex.wordpress/Function_Reference/media_handle_upload
Maybe this can help you out. This function handles the upload of the file and adds the attachment as WordPress media record. Don't forget to include dependencies if you're uploading from frontend.