1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How To Upload A File In Wordpress?

Discussion in 'WordPress' started by sangeetha2013, Feb 19, 2013.

  1. #1
    I had created WordPress Plugin to upload images to media gallery..Image uploaded to the media gallery,But its not visible in Media Gallery...Can anyone help to sort this problem..
    I Pasted code below:

    <?php
    /*
    Plugin Name: Logo Display for header
    Plugin URI: http://www.falkonproductions.com/firstPlugin/
    Description: This plugin does things you never thought were possible.
    Author: Drew Falkman
    Version: 1.0
    Author URI: http://www.falkonproductions.com/

    Copyright 2010 Drew Falkman

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    */
    function wptuts_get_default_options() {
    $options = array(
    'logo' => ''
    );
    return $options;
    }
    function wptuts_options_init() {
    $wptuts_options = get_option( 'theme_wptuts_options' );

    // Are our options saved in the DB?
    if ( false === $wptuts_options ) {
    // If not, we'll save our default options
    $wptuts_options = wptuts_get_default_options();
    add_option( 'theme_wptuts_options', $wptuts_options );
    }

    // In other case we don't need to update the DB
    }

    // Initialize Theme options
    add_action( 'after_setup_theme', 'wptuts_options_init' );
    // Add "WPTuts Options" link to the "Appearance" menu
    function wptuts_menu_options() {
    // add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);
    add_theme_page('Logo Option', 'Logo Options', 'edit_theme_options', 'wptuts-settings', 'wptuts_admin_options_page');
    }
    // Load the Admin Options page
    add_action('admin_menu', 'wptuts_menu_options');

    function wptuts_admin_options_page() {
    ?>
    <!-- 'wrap','submit','icon32','button-primary' and 'button-secondary' are classes
    for a good WP Admin Panel viewing and are predefined by WP CSS -->
    <!--
    -->
    <div class="wrap">
    <?php screen_icon(); ?>
    <h2>Upload header logo</h2>
    <p>Welcome to the Display logo Plugin. Here you can upload images to your header logo.</p>
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>
    </div>
    <?php
    }
    sangeetha2013, Feb 19, 2013 IP
  2. Sayedtaqui

    Sayedtaqui Greenhorn

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #2
    Code (Text):
    1. I had [B]created[/B] WordPress Plugin to upload images to media gallery..
    Are you creating this plugin? (but the autor name is different.), and when wordpress already has the option of uploading images to the gallery , why are you using a plugin?
    Sayedtaqui, Feb 21, 2013 IP
  3. sangeetha2013

    sangeetha2013 Greenhorn

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    ya, I m going to create a Plugin to change the theme logo and I want to fetch one image from media Library and set it for my theme header logo Pls help me sort out this problem..
    Below is my Plugin code

    <?php
    /*
    Plugin Name: Logo Display for header
    Plugin URI: http://www.falkonproductions.com/firstPlugin/
    Description: This plugin does things you never thought were possible.
    Author: Drew Falkman
    Version: 1.0
    Author URI: http://www.falkonproductions.com/

    Copyright 2010 Drew Falkman


    */

    function wptuts_get_default_options() {
    $options = array(
    'logo' => ''
    );
    return $options;
    }
    function wptuts_options_init() {
    $wptuts_options = get_option( 'theme_wptuts_options' );

    // Are our options saved in the DB?
    if ( false === $wptuts_options ) {
    // If not, we'll save our default options
    $wptuts_options = wptuts_get_default_options();
    add_option( 'theme_wptuts_options', $wptuts_options );
    }

    // In other case we don't need to update the DB
    }

    // Initialize Theme options
    add_action( 'after_setup_theme', 'wptuts_options_init' );
    // Add "WPTuts Options" link to the "Appearance" menu
    function wptuts_menu_options() {
    // add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);
    add_theme_page('Logo Option', 'Logo Options', 'edit_theme_options', 'wptuts-settings', 'wptuts_admin_options_page');
    }
    // Load the Admin Options page
    add_action('admin_menu', 'wptuts_menu_options');

    function wptuts_admin_options_page() {
    ?>
    <!-- 'wrap','submit','icon32','button-primary' and 'button-secondary' are classes
    for a good WP Admin Panel viewing and are predefined by WP CSS -->


    <div class="wrap">
    <?php screen_icon(); ?>
    <h2>Upload header logo</h2>
    <p>Welcome to the Display logo. Here you can upload images to your header logo.</p>
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to Media gallery:
    </form>


    <?php
    }
    sangeetha2013, Feb 21, 2013 IP
  4. Sayedtaqui

    Sayedtaqui Greenhorn

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #4
    You question is still not clear. Are you a devloper ? I have created a wordpress theme myself. Some themes have the inbuild option to change the logo image from gallery. If you are looking for a plugin to change the logo of your current theme, you can put a link of your website and I can tell you how to change the logo. But if you are a devloper and creating a plugin for other people and planning to upload it to wordpress codex, why are you showing the plugin code of some other author(that doesn't make sense to me)? Please explain what you are tying to do. And if you have written your own code for plugin show me that one. or else just paste the link to your website.
    Sayedtaqui, Feb 21, 2013 IP
  5. sangeetha2013

    sangeetha2013 Greenhorn

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #5
    Actually I am studying and we got a project to build a Plugin, the topic is on particular date my website logo should get change for example valentine day feb 14 the logo of the image should change according to that event . But my doubt is I want a option to select image from media Library and date also for Logo and Display that Logo on particular Day....
    sangeetha2013, Feb 22, 2013 IP
  6. Sayedtaqui

    Sayedtaqui Greenhorn

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #6
    hmm.. I get it. But have you written some code for it. Because you see nobody is going to write the whole plugin for you(because if they wanted to, they would released the plugin under their name). People can only help you fix the errors in code of the plugin that you would might have. I would suggest that you should read this http://codex.wordpress.org/Writing_a_Plugin and if you have any questons you should ask that on wordpress support. http://wordpress.org/support/
    Sayedtaqui, Feb 22, 2013 IP