Forums

How to make a plugin with file upload (4 posts)

  1. SteeleR
    Member
    Posted 1 year ago #

    Hi, i'm trying to write a plugin and I need the admin to have the option to upload files(images). As of the moment i got:

    <form method="post" action="options.php" enctype="multipart/form-data">
        <?php wp_nonce_field('update-options'); ?>
        <table width="100%" style="text-align: left;">
            <tr valign="top">
                <th width="250" scope="row">Background Image</th>
                <td>
                    <input name="mypg_image" type="file" id="mypg_image" value="" />
                </td>
            </tr>
            <tr valign="top">
                <th width="250" scope="row">Image Title</th>
                <td>
                    <input name="mypg_title" type="text" id="mypg_title" value="<?php echo get_option('mypg_title'); ?>" />
                </td>
            </tr>
        </table>
    
        <input type="hidden" name="action" value="update" />
        <input type="hidden" name="page_options" value="mypg_title, mypg_image" />
        <p>
            <input type="submit" value="<?php _e('Save Changes') ?>" />
        </p>
    </form>

    and there is no problem working with the text fields, but how should a file upload be managed ?

  2. schmeal
    Member
    Posted 1 year ago #

    Any luck finding a solution to this? I'm looking for a similar solution to being able to upload files from an admin area, I need to process the files once they are uploaded, but I have already written a PHP function to do that. I just need to get the file up to the site.

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

  4. schmeal
    Member
    Posted 1 year ago #

    Thanks! I'm looking at it right now.

Topic Closed

This topic has been closed to new replies.

About this Topic