Welcome Guest, Not a member yet? Register   Sign In
Strange problem with file upload
#6

(02-19-2018, 06:47 PM)LEBOSSS Wrote: Thank you @kirasiris, i made all of yur suggested modifications but no way. It's not working.
I want to ask one question: Is it possible that a file has mp3 extension but is not mp3 file?

This is what your code should look if you want it to send it to a database and into a folder.

PHP Code:
            // Upload mp3/Ogg File
            
$config['upload_path'] = 'uploads/musiques/';
            
$config['allowed_types'] = 'mp3|ogg';
            
$config['encrypt_name'] = TRUE;
            
$config['file_ext_tolower'] = 'TRUE';
            
$config['remove_spaces'] = 'TRUE';
            
$this->load->library('upload'$config);
            
$this->upload->initialize($config);
                    
            
            
$file_name 'mymusic';
            
            if(!
$this->upload->do_upload($file_name)){
                
var_dump($this->upload->display_errors());
                
$file_name 'uploads/musiques/nofileselected.jpg';
            } else {
                
$post_image  $this->upload->data('file_name');
            }
            
            
// If you want to send it to your database as well, you have to put it like this:
 
           $data = array(
                
'slug'            => $slug,
                
'title'            => $this->input->post('title'),
                
'mymusic'    => $post_image,
 
           ); 

try and see if it works, and to respond your second question about uploading a file that looks like an mp3 file but its not, I will highly recommend you to convert any file into mp3 before uploading just to  make sure you dont mess with uploading class; or if you have any idea of what the real extension of the file is, then added it to the allowed_types parameter and see if it works.
I do Front-End development most of the time 
Reply


Messages In This Thread
Strange problem with file upload - by LEBOSSS - 02-19-2018, 04:37 PM
RE: Strange problem with file upload - by LEBOSSS - 02-19-2018, 05:15 PM
RE: Strange problem with file upload - by LEBOSSS - 02-19-2018, 06:47 PM
RE: Strange problem with file upload - by kirasiris - 02-19-2018, 07:13 PM
RE: Strange problem with file upload - by LEBOSSS - 02-19-2018, 07:34 PM
RE: Strange problem with file upload - by LEBOSSS - 02-20-2018, 07:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB