WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] front-end attaching image to post (create gallery tab in media uploader)

[Resolved] front-end attaching image to post (create gallery tab in media uploader)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Well the first problem you have is method=”post” should be the enctype multipart/form-data or else it’s never even going to see the upload.

    This documentation is used for the wp admin meta boxes but you can probably strip some information out of it that is pertinent to what you are trying to do:

    http://www.trovster.com/blog/2011/07/wordpress-custom-file-upload

    thank you for your reply. i could not get the code from that link to work with the media uploader. everywhere i look for this solution they all create a new upload form. i can’t use that code because i can’t grab the uploaded image url from the media uploader without javascript and that creates a whole bunch of other problems for me, (i want the media uploader to handle all the image processing anyway). but i finally found my solution here: http://wordpress.org/support/topic/wp_editor-media-upload?replies=6

    now the code from my theme page where the post is processed looks like this

    <?php
     //information sent from the response pages that have the template Response Template page
    get_currentuserinfo();
    $loggedInNow = $current_user->ID;
    $response = wp_insert_post(array(
    'ID' => $_POST['postempty'],
    'comment_status' => 'closed',
    'post_title' => $_POST['postTitle'],
    'post_content' => $_POST['responsesubmit'],
    'post_author' => $loggedInNow,
    'post_status' => 'publish',
    'post_type' => 'post'
    );
    
     global $post_ID;
     $post_ID = $emptynew;
    ?>

    i added enctype=”multipart/form-data” in my form with wp_editor in it for good measure. so simple, i wish this was documented, did not come across it in google easily.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] front-end attaching image to post (create gallery tab in media uploader)’ is closed to new replies.
Skip to toolbar