Very simple upload form for wordpress plugin

I have a very simple plugin in my wordpress. Now i have a function and i use add_submenu_page to add that function to my main function (plugin).

I want to add a upload form to upload images in this submenu_page . Images should be uploaded to wp-content/uploads.

Read More

So is there any simple form to do this? I want to do it with main wp functions but i don’t know how to do it.

Just needing a simple form to upload images in wp-content/uploads folder. How to do it ?

Thanks.

Related posts

Leave a Reply

1 comment

  1. i did the following for a plugin i built. Dead simple!

    Firsty you need to enqueue the wordpress media upload like so:

    add_action('admin_enqueue_scripts', 'my_scripts');
    function my_scripts() {
            wp_enqueue_media();
    
    }
    

    You then need to give the the input button an id of upload_image_button here’s an example:

    <input id="upload_image_button" class="button" type="button" value="Select Logo" />
    

    To display the file location in an input, use the following:

    <input size="50" id="upload_image" type="text" name="ad_image" value="" />
    

    I hope this helps!