WordPress.org

Ready to get started?Download WordPress

Forums

Upload in theme option page (7 posts)

  1. alemao85
    Member
    Posted 1 year ago #

    Hello,
    I am creating my own theme. And everything works well.
    But now I want to add an upload form to the theme option page.
    I have tried all kinds of uploaders but nothing worked so I decided to try my own idea.

    On the theme option page I have a form, where all the inputs are. I just added a file input. But now when I click on save options it wont upload the image. Itried to output file name or size, but its all empty.

    Does anyone have help?

    Thanks :)

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

  3. alemao85
    Member
    Posted 1 year ago #

    I added the theme options by using this code

    function theme_options_add_page() {
    	add_theme_page('Configuração', 'Configuração', 'edit_theme_options', 'theme-optionen', 'kb_theme_options_page' );
    }

    I think, yes, that settings API.

  4. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    File upload fields require changing the form enctype to "multipart/form-data".

    You'll want to use wp_handle_upload() to handle the file upload in your settings validation callback.

  5. alemao85
    Member
    Posted 1 year ago #

    I have "multipart/form-data" in my form.

    Can you tell me how I have to change this:

    echo $_FILES['file']['name'] ;

    to make it work?

    Thanks

  6. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    Can you tell me how I have to change this:

    echo $_FILES['file']['name'] ;

    to make it work?

    Not without seeing all of the relevant code. Can you post your Theme options code in its entirety in a Pastebin, and link to it here?

  7. alemao85
    Member
    Posted 1 year ago #

    http://pastebin.com/hpfVMgLd

    The parts that I meand are in line 30 and 53.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.