save image in upload folder

  • Unknown's avatar

    Hi guys
    i want to create a field in user profile to upload image for use in author page .
    and so i write the following codes but image url insert in database but photo can not be saved in upload folder
    please help me!

    add_action( ‘show_user_profile’, ‘my_show_extra_profile_fields’ );
    add_action( ‘edit_user_profile’, ‘my_show_extra_profile_fields’ );

    function my_show_extra_profile_fields( $user ) { ?>

    <h3>Extra profile information</h3>

    <table class=”form-table”>

    <tr>
    <th><label for=”Linkedin”>Header Photo</label></th>

    <td>
    <input type=”file” name=”Header” id=”Header” value=”<?php echo esc_attr( get_the_author_meta( ‘Header’, $user->ID ) ); ?>” class=”regular-text” />
    <span class=”description”>عکس هدر صفحه پروفایل خود را آپلود کنید</span>
    </td>
    </tr>
    </table>
    <?php }
    add_action( ‘personal_options_update’, ‘my_save_extra_profile_fields’ );
    add_action( ‘edit_user_profile_update’, ‘my_save_extra_profile_fields’ );

    function my_save_extra_profile_fields( $user_id ) {
    $uploadUrl= wp_get_upload_dir();
    if ( !current_user_can( ‘edit_user’, $user_id ) )
    return false;

    /* Copy and paste this line for additional fields. Make sure to change ‘twitter’ to the field ID. */
    update_usermeta( $user_id, ‘Header’, $uploadUrl[‘url’].”/”.$_POST[‘Header’] );
    }

  • Unknown's avatar
  • Unknown's avatar

    up

    Hi. You are in the wrong place.
    These forums are only for blogs/sites hosted by WordPress.com

    WordPress.COM and WordPress.ORG are completely separate and different http://support.wordpress.com/com-vs-org/

    And you should ask in the WordPress.org forums.
    http://wordpress.org/support

  • The topic ‘save image in upload folder’ is closed to new replies.