0

please help me on my project on how do i make this upload music files also help me on making the upload path i don't know how to start. i really do need your help guys :(

this the controller

<?php if(!defined('BASEPATH')) exit('no direct script access allowed');
    session_start(); //we need to call PHP's session object to access it through CI

    class home extends CI_Controller
    {

        public function __construct()
        {
            parent::__construct();
        }

        public function index()
        {


            if($this->session->userdata('logged_in'))
            {
                $session_data = $this->session->userdata('logged_in');
                $data['username']= $session_data['username'];
                $this->load->view('home_view',$data);
            }
            else
            {
                //if no session , redirect to login page
                redirect('login','refresh');
            }
        }

    public function uploadfile()
    {
        // Has the form been posted?
        if (isset($_POST['submit']))
        {
        // Load the library - no config specified here
        $this->load->library('upload');

        // Check if there was a file uploaded - there are other ways to
        // check this such as checking the 'error' for the file - if error
        // is 0, you are good to code
        if (!empty($_FILES['userfile']['name']))
        {
            // Specify configuration for File 1
            $config['upload_path'] = '../upload';
            $config['allowed_types'] = 'mp3|wav|aif|aiff|ogg';
            $config['max_size'] = '256000';


            // Initialize config for File 1
            $this->upload->initialize($config);

            // Upload file 1
            if ($this->upload->do_upload('userfile'))
            {
                $data = $this->upload->data();
            }
            else
            {
                echo $this->upload->display_errors();
            }

        }

        // Do we have a second file?
        if (!empty($_FILES['userfile1']['name']))
        {
            // Config for File 2 - can be completely different to file 1's config
            // or if you want to stick with config for file 1, do nothing!
            $config['upload_path'] = '../upload';
            $config['allowed_types'] = 'mp3|wav|aif|aiff|ogg';
            $config['max_size'] = '256000';


            // Initialize the new config
            $this->upload->initialize($config);

            // Upload the second file
            if ($this->upload->do_upload('userfile1'))
            {
                $data = $this->upload->data();
            }
            else
            {
                echo $this->upload->display_errors();
            }

        }
    }
    else
    {
        redirect('home');
    }
        }

        public function logout()
        {
            $this->session->unset_userdata('logged_in');
            session_destroy();
            redirect('login');
        }







}


?>

and this is the view

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title>Private Area</title>
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <?php echo link_tag('css/themes/default/jquery.mobile-1.1.1.css'); ?>
    <script src="<?php echo base_url(); ?>js/jquery.js"></script>
    <script src="<?php echo base_url(); ?>js/jquery.mobile-1.1.1.min.js"></script>
</head>

<body data-role="page">

    <div data-role="header">
    <h1>Home</h1>
    </div>

    <h2>Welcome <?php echo $username; ?>!</h2>

<div data-role="content">        
<?php echo form_open_multipart('home/uploadfile');  ?>

    <?php echo form_label('File 1', 'userfile'); ?>
    <?php echo form_upload('userfile'); ?>


    <?php echo '<br/>' . form_label('File 2', 'userfile1'); ?>
    <?php echo form_upload('userfile1'); ?>

<?php echo form_submit('submit', 'Upload File'); ?>
<?php echo form_close(); ?>
</div>



    <a href="home/logout" data-role="button" data-inline="true" data-mini="true" data-theme="a">Logout</a>

</body>
</html>
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by LastMitch
0

@nicoalmighty

please help me on my project on how do i make this upload music files also help me on making the upload path i don't know how to start. i really do need your help guys :(

I presume you are using CodeIgniter mainframe! What is the issue or error you are getting? You didn't mention it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.