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?
https://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.