lundi 20 juin 2016

How get url of uploaded image in Wordpress (wp_handle_upload)

I added tab to admin menu page and input where it is possible to upload files.

function logo_display(){?>
    <input type="file" name="logo" /> 
    <?php echo get_option('logo'); ?><?php}

Files are saved after upload but I don't know how to display them on frontpage. My function:

function handle_logo_upload($option){
if(!empty($_FILES["logo"]["tmp_name"]))
{
    $urls = wp_handle_upload($_FILES["logo"], array('test_form' => FALSE));
    $temp = $urls["url"];
    return $temp;   
}

return $option;}

In function to display page i registered this function:

register_setting("section", "logo", "handle_logo_upload");

All I want is to get the url of uploaded image but I don't know how to refer to this.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire