How to allow users to upload images on WordPress?

I’m developing a WordPress site that will let (registered) users upload an image and description to a gallery, but am not sure the best way to do so.

I do not want them to do it through the back end of the site, but rather a “Your Projects” page on the site with a form. The form will have a few text fields and the file upload area.

Read More

I was thinking of trying to adapt Contact Form 7 to handle this, but not sure if it’s even possible.

Are there any plugins out there that would do this? Thanks

Related posts

Leave a Reply

2 comments

  1. Your best bet is to create a custom plugin to do it with something like:

    $wp_filetype = wp_check_filetype(basename($filename), null );
    $attachment = array(
       'post_mime_type' => $wp_filetype['type'],
       'post_title' => preg_replace('/.[^.]+$/', '', basename($filename)),
       'post_content' => '',
       'post_status' => 'inherit'
    );
    $attach_id = wp_insert_attachment( $attachment, $filename, 37 );
    // you must first include the image.php file
    // for the function wp_generate_attachment_metadata() to work
    require_once(ABSPATH . "wp-admin" . '/includes/image.php');
    $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
    wp_update_attachment_metadata( $attach_id,  $attach_data );