Welcome Guest, Not a member yet? Register   Sign In
Problem Uploading Mp3 and Video files
#1

[eluser]ranacse05[/eluser]
Hello experts i'm facing problem with uploading mp3 and video (3gp and mp4) files via upload class.
Here is my code
Code:
$config['upload_path'] = './uploads/mp3';
        $config['allowed_types'] = 'mp3';
        $config['max_size']    = '2048';

The Error massage i get by this code
Code:
$error = array('error' => $this->upload->display_errors());
            
            
            print_r($error);

And the massage is

Code:
Array ( [error] =>

The filetype you are attempting to upload is not allowed.
)

How can i get rid of it ? And what file type will be for video ?? will it
Code:
$config['allowed_types'] = '3gp|mp4';

Thanks in advance.
#2

[eluser]nirbhab[/eluser]
For Error Messages:
Go toConfusedystem/language/english/upload_lang.php

And File-Type for Video Uploading depends upon, which you want to get supported by server+your application scope.
Video types: http://www.fileinfo.net/filetypes/video.
Visit the above URL.
#3

[eluser]ranacse05[/eluser]
OK but what about the mp3 files ? I saw them listed on mime.php so why i cant upload mp3 via CodeIgniter ?
#4

[eluser]nirbhab[/eluser]
you can upload any file of your choice, add the EXT of the file in the mime type, it won't give any problem at all. I haven't tried uploading mp3 file type. if you facing too much problem, let us know..we try to code and let you know the changes we have done or try to share our code.
#5

[eluser]ranacse05[/eluser]
Dear here is my code for mp3 upload
Code:
<?php
class uploadmp3 extends controller    {

    function uploadmp3()
        {
        
        parent::controller();
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->database();
        }

    
    function index()
        {
        
        $this->load->view('add_mp3');
        
        }
        
    function do_upload()
        {
        $config['upload_path'] = './uploads/mp3';
        $config['allowed_types'] = 'mp3';
        $config['max_size']    = '2048';
        
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            
            //$this->load->view('error', $error);
            print_r($error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
        
        if($this->db->query($sql))    
            $this->load->view('success');
    
        }
        
    }

}

?>

and here for video

Code:
?php
class uploadvideo extends controller    {

    function uploadvideo()
        {
        
        parent::controller();
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->database();
        }

    
    function index()
        {
        
        $this->load->view('add_video');
        
        }
        
    function do_upload()
        {        
        $config['upload_path'] = './uploads/video';
        $config['allowed_types'] = '3gp|mp4';
        $config['max_size']    = '2048';

        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            
            $this->load->view('error', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
        
        if($this->db->query($sql))    
            $this->load->view('success');
    
        }
        
    }

}

?>

Please help me to find out the solution.
#6

[eluser]nirbhab[/eluser]
Code Seems ok to me, i hope the file you are uploading by 'uploadmp3' class is XYZ.mp3?
Please do consider the extension of uploading file.....
#7

[eluser]ranacse05[/eluser]
Yes of course its mp3.
#8

[eluser]dione[/eluser]
hi there im stuck with the same problem with mp3's...

Uploading works smooth with firefox. but not IE and Safari. Other than firefox i get...
"The filetype you are attempting to upload is not allowed"

This is in my mime.php
Code:
'mp3'    =>    array('audio/mpeg','audio/mpeg3','audio/mpg'),
i also tried
Code:
'mp3'    =>    'audio/mpg',
#9

[eluser]Zeeshan Rasool[/eluser]
Guys ,i think this one can make it posible plz try it ,

'mp3' => array('audio/mpeg','audio/mpeg3','audio/mpg','audio/x-mpeg','audio/mp3'),
Hope it works.
.................JaMzEe
#10

[eluser]bugzbrown[/eluser]
I´ve had the same problem... I tried a series of possibilities until I discovered my firefox was setting the content-type to 'application/force-download' and my explorer was setting the type to 'application/octet-stream'.

by setting my mime to this:

'mp3' => array('audio/mpeg','audio/mpeg3','audio/mpg','audio/x-mpeg','audio/mp3','application/force-download','application/octet-stream'),

I solved the problem in all browsers.

Hope this helps you all.




Theme © iAndrew 2016 - Forum software by © MyBB