How to upload and add images to the existing post from the front-end with admin approval which is posted by other user

This is a way to add post images and other things. So put different check on it according to your need.

<?php
    if( 'POST'  == $_SERVER['REQUEST_METHOD' ] && !empty( $_POST['action' ] ) &&  $_POST['action' ] == "new_post") {
                if (isset ($_POST['post_title'])) {
                        $post_title =  $_POST['post_title'];
                    }


            $post = array(
                        'post_title'    => $post_title,
                        'post_content'  => $post_content,
                        'post_category' => array($post_category),
                        'tags_input'    => array($post_tags),
                        'post_status'   => 'draft',
                        'post_type' => 'post'
                    );

                $post_id = wp_insert_post($post);
                wp_set_post_tags($post_id, $post_tags);


                if (!empty($_FILES['file_0']['name'])) {
                  foreach ($_FILES as $file_id => $array) {
                    $attachment_id = insert_attachment($file_id,$post_id,true);
                  }
                 //send_mail_on_post_submit($userEmail);
            $success = __('This post is awaiting approval by the moderators', 'frontendprofile');


            }
            unset($_POST);


    }
    ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)