0

I'm trying to upload a wmv file in server folder and name in database and I want to display the length of that file in seconds.

<audio id="myaudio" controls>
        <source src="res->voice_path" type="audio/wmv">
        <source src="res->voice_path" type="audio/ogg">
        Your browser does not support the audio element.
    </audio>

<script>
    var vid = document.getElementById("myaudio");

    function myFunction() {
        alert(vid.duration);
    }
</script>

Here, I can get the audio length in alert box but I need that to echo how to take that value into a variable and echo that in CodeIgniter.

The above code I used in a view.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ahmed
  • 7
  • 5
  • `wmv` is video file extension. Did you mean `wav`? – Tpojka Apr 17 '17 at 13:27
  • sorry my mistake wav file length how to get that and need to upload using ajax.. – Ahmed Apr 17 '17 at 17:09
  • Those are two questions/problems. 1.) Upload file with AJAX and 2.) audio file manipulation. Check [answer here](http://stackoverflow.com/questions/9140023/sound-library-for-php-developement) for second one. For first one just google or search on site for "codeigniter ajax file upload". – Tpojka Apr 17 '17 at 18:21

1 Answers1

-1
$this->load->model('songshare/Songmodel');
    $this->Songmodel->songupload($data);
    //upload data

    $config['upload_path'] = realpath(APPPATH.'../uploads/');
    $config['max_size']    = '0';
    $config['allowed_types'] = 'mp3|wav';
    $this->load->library('upload', $config);


    if (!$this->upload->do_upload('userfile')) {
        $data = array('msg' => $this->upload->display_errors());

    } else { //else, set the success message
        $data = array('upload_data' => $this->upload->data());
                    $field = 'userfile';                        
                    var_dump($_FILES[$field]['type']);
    }

https://www.youtube.com/watch?v=RW8ajjvJwMI

hamed hossani
  • 986
  • 2
  • 14
  • 33
  • how to get the length of that wmv file which we are uploaded. audio length which I wanted to display – Ahmed Apr 17 '17 at 11:04