Laravel.io
<?php /* Template Name: Add New Album Zip4 folder*/
get_header(); ?>

<div class="container">

    <div class="col-md-8 add_album">

        <?php   include_once ABSPATH . 'wp-admin/includes/media.php';
        include_once ABSPATH . 'wp-admin/includes/file.php';
        include_once ABSPATH . 'wp-admin/includes/image.php';

//Random Id post generation
        $randomid = rand(5, 9999);

        if (isset($_POST['categorite'])) {
            $categorite = $_POST['categorite'];
        }

        if ( !empty( $_POST['post_title'] ) ) {
// Create post object
            $my_post = array(
                'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
                'post_content' => wp_strip_all_tags( $_POST['post_content'] ),
                'post_status' => 'pending',
                'import_id' => $randomid,
                'post_category' => $categorite
                );

// Insert the post into the database
            $parent_post_id = wp_insert_post( $my_post );

            global $post;

            if(isset($_FILES['image_upload'])) {
                $filename = $_FILES['image_upload']['name'];
                $source = $_FILES['image_upload']['tmp_name'];
                $type = $_FILES['image_upload']['type'];
            }

            WP_Filesystem();
            $destination = wp_upload_dir();
            $destination_path = $destination['path'];
            $unzipfile = unzip_file( $destination_path. '/' .$filename, $destination_path);

           // $album_directory =  wp_mkdir_p('/home/klevinko/public_html/chuck/wp-content/uploads/albums/' . $time);

///http://php.net/manual/en/function.scandir.php
            $scannedfiles = scandir ($destination_path);
            //$audiofiles = array_slice($scannedfiles,  1);

            // Prepare an array of post data for the attachment.


            foreach ($scannedfiles as $file => $array ) {

                $attachment = array(
                    'post_mime_type' => $filetype['type'],
                    'post_title'     => $array,
                    'post_content' => '',
                    'post_status' => 'inherit'
                    );

                print_r($array); ?></br><?php
                print_r($filename); ?></br><?php
                print_r($attachment); ?></br><?php

                $attachment_id = wp_insert_attachment( $attachment, $array, $randomid );
            }


            if ( $unzipfile ) { echo 'Successfully unzipped the file!'; } else {
                echo 'There was an error unzipping the file.';  }

                //wp_update_attachment_metadata($parent_post_id, $attachment_id );

// Insert the attachment.
//$attach_id = wp_insert_attachment( $attachment_id , $filename, $parent_post_id );

// Generate the metadata for the attachment, and update the database record.
            }?>

            <h2>Add you Album</h2>
            <p>In order to view the album after you inserted it should be approved from the administrator</p>

            <form action="" method="post" enctype="multipart/form-data">

                <fieldset>
                    <label>Album Category</label>
                    <?php $categories = get_categories(array('hide_empty'=> 0));
                    foreach ( $categories as $category ) { ?>
                    <input type="checkbox" name="categorite[]" value="<?php echo $category->cat_ID;?>">
                    <?php echo $category->cat_name; ?>
                    <?php }?>
                </fieldset>

                <fieldset>
                    <label for="post_title"><?php _e('Album Title:', 'framework') ?></label>

                    <input type="text" name="post_title" id="post_title" />
                </fieldset>

                <fieldset>
                    <label for="post_content"><?php _e('Album Desription:', 'framework') ?></label>

                    <textarea name="post_content" id="post_content" rows="8" cols="30"></textarea>
                </fieldset>

                <fieldset>
                    <label>Album song</label>
                    <input type="file" name="image_upload" id="image_upload" multiple="false" />
                </fieldset>
                <button type="submit"><?php _e('Insert Album', 'framework') ?></button>
            </form>
        </div>

        <div class="row">
            <?php get_sidebar( 'home' ); ?>
        </div>

        <?php get_footer();?>

Please note that all pasted data is publicly available.