Can't upload ogg or ogv file - php

I can't upload ogg / ogv file. the error message is
The filetype you are attempting to upload is not allowed.
I have tried this in the mimes.php
'ogg' => array('application/x-ogg', 'application/ogg', 'audio/x-ogg, application/octet-stream'),
'ogv' => array('application/ogv', 'video/ogv')
and in the controller
$config['upload_path'] = 'assets/assets/video/';
$config['allowed_types'] = 'ogv|ogg';
$config['file_name'] = "samsame";
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
$this->upload->do_upload('videoname');
$error = $this->upload->display_errors();

You have to initialize the $config array, so your problem will be solved. You are trying to upload without initializing. Please write the below line after loading the library.
$this->upload->initialize($config);
Also check that your form must be multipart
You can also rewrite the $config array if above solution dose't work. Here sample_simage
is the name of input type.
$allowed_types = 'ogg|ogv';
$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = substr($allowed_types, strpos($allowed_types,substr($_FILES['sample_simage']['name'], -3)), 3);
$this->load->library('upload', $config);
$this->upload->do_upload('sample_simage');

Related

Unable to upload these formate file in codeigniter STEP, STP, IGES, IGS, SLDPRT, 3DM, SAT or X_T

Unable to upload these formate file in codeigniter STEP, STP, IGES, IGS, SLDPRT, 3DM, SAT or X_T
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf|step';
$config['max_size'] = 100000000000;
//$config['max_width'] = 1024;
// $config['max_height'] = 768;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('fileUpload'))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
// echo 'error';
// $this->load->view('upload_form', $error);
}else{
$this->upload->data();
}
error :- The filetype you are attempting to upload is not allowed
for those file types, just change your config of allowed_types into this to override checking extension:
$config['allowed_types'] = "*";
Before uploading your file, codeigniter check your file's extension first, but your file types are not in application/config/mimes.php so codeigniter does not know and then always return FALSE.
Another way is to add your mimes type into mimes.php, you can check out this in this link

Codeigniter Image upload ignore allowed types and file size

I have below code to upload user image, my code work good but I'm getting issue while checking allowed_types i.e. png|jpg and max_size..
It doesn't check allowed type and max size
Code:
$this->load->library('upload');
$config['upload_path'] = 'admin/upload/';
$config['allowed_types'] = 'jpg|jpeg';
$config['max_size'] = '100';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->upload->set_allowed_types('*');
if (!$this->upload->do_upload('user_image')){
$data = array('msg' => $this->upload->display_errors());
$flag="1";
}else {
$image_path = $this->upload->data();
$flag="2";
}
Output:
$flag always set to 2...even I uploaded file .png or .gif and same problem for max_size
Try increasing the max_size. Also remove the line $this->upload->set_allowed_types('*');

CodeIgniter FileUpload Not Allowed

I'm setting up an upload form in CodeIgniter. I've setup the allowed_types parameter to:
$config['allowed_types'] = 'xls|xlsx';
And added the following line to config/mimes.php:
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
However, despite the file I'm trying to upload being an xlsx file CI is still telling me the filetype isn't allowed. Any thoughts?
public function do_upload() {
// Change this if you change the upload directory
$upload_path = "/webusers/ad6vcf/public_html/funding_manager/application/uploads";
$config['upload_path'] = $upload_path;
//At some point will add support for csv
$config['allowed_types'] = 'xls|xlsx';
//Max 5000kb please
$config['max_size'] = '5000';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->upload($error);
} else {
$upload_data = $this->upload->data();
bulk_insert($upload_path . $upload_data['file_name']);
}
}
Please try this
$this->load->library('upload', $config);
$this->upload->initialize($config);
Have you tried this?
if (!$this->upload->do_upload('put the name of the input field here'))

codeigniter upload multiple file different directory

In my form have 3 file upload input option.
bot are going to different directory. I can work with one directory but not work with multiple.
My code
$config['upload_path'] = './uploads/video';
$config['allowed_types'] = 'flv|mov|m4v|mp4';
$config['max_size'] = '30720';
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
$this->upload->do_upload('userfile');
$video_upload=$this->upload->data();
$config2['upload_path'] = './uploads/video';
$config2['allowed_types'] = 'jpg|jpeg|bmp|png';
$config2['max_size'] = '30720';
$config2['encrypt_name'] = TRUE;
$this->load->library('upload', $config2);
$this->upload->do_upload('thumbnail1');
$thumbnail_upload=$this->upload->data();
here video file upload successfully but image file not upload
$this->load->library() doesn't reload or reinitialize the library if it's already loaded.
In this case, you need to modify the existing loaded library options:
$this->upload->initialize($config2);
instead of
$this->load->library('upload', $config2);
Should do the trick.

how can I change allowed file type in codignetor which actually work?

Here is my controller code but only jpg and png file are uploaded I also changed it my process model.php also.
Is there any way to change it? And it doesn’t show any warning. You can check it from here but you need to register first...
public function saveTestimonial() {
$config['upload_path'] = './testimonial_photo/';
$config['allowed_types'] = 'gif|jpg|png|psd|zip|tif|ai|eps';
$config['max_size'] = '1024';
$config['max_width'] = '10240';
$config['max_height'] = '7680';
You should declare file upload like the below code. Since you are uploading images, docx, zip files you should not declare max_width and max_height. But you can change the max_size for the file.
$config['upload_path'] = 'testimonial_photo/';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->upload->set_allowed_types('gif|jpg|png|jpeg|zip|pdf|doc|docx');
$this->upload->do_upload('filename_in_html_input')

Categories