Uploading zip and rar file not working in codeigniter
Tag : php , By : UpperLuck
Date : March 29 2020, 07:55 AM
this will help setting i have created for allowed type: , i replace the mime.php configuration for zip and rar to: 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed','application/force-download','application/octet-stream'),
'rar' => array('application/x-rar', 'application/rar','application/x-rar-compressed','application/force-download','application/octet-stream'),
|
File uploading is not working properly in codeigniter
Tag : php , By : Chris Woods
Date : March 29 2020, 07:55 AM
may help you . I am using code-igniter to upload files with two input boxes . But my code not uploading both the files i m getting same file two times. , Please change your PHP code and try this out $this->upload->do_upload()
$this->upload->do_upload($field_name)
|
Error on uploading CSV File in Codeigniter
Date : March 29 2020, 07:55 AM
may help you . Instead of changing the mime type you can go with the CALLBACK function This will add more portability too... function importcsv() {
$data['addressbook'] = $this->csv_model->get_addressbook();
$data['error'] = ''; //initialize image upload error array to empty
$this->form_validation->set_rules('uploaded_file','Uploaded file', 'trim|callback_chk_attachment');
if($this->form_validation->run()){
$config['upload_path'] = './uploads/';
$config['allowed_types'] = '*';
$config['max_size'] = '1000';
$this->load->library('upload', $config);
// If upload failed, display error
if (!$this->upload->do_upload()) {
$data['error'] = $this->upload->display_errors();
$this->load->view('csvindex', $data);
} else {
$file_data = $this->upload->data();
$file_path = './uploads/'.$file_data['file_name'];
if ($this->csvimport->get_array($file_path)) {
$csv_array = $this->csvimport->get_array($file_path);
foreach ($csv_array as $row) {
$insert_data = array(
'firstname'=>$row['firstname'],
'lastname'=>$row['lastname'],
'phone'=>$row['phone'],
'email'=>$row['email'],
);
$this->csv_model->insert_csv($insert_data);
}
$this->session->set_flashdata('success', 'Csv Data Imported Succesfully');
redirect(base_url().'csv');
//echo "<pre>"; print_r($insert_data);
} else
$data['error'] = "Error occured";
$this->load->view('csvindex', $data);
}
}
Call Back function for File Upload validation:
public function chk_attachment() // callback validation for check the attachment extension
{
$file_type = array('.csv');
if(!empty($_FILES['uploaded_file']['name']))
{
$ext = strtolower(strrchr($_FILES['uploaded_file']['name'],"."));
if(in_array($ext,$ext_array))
{
return true;
}
else
{
$this->form_validation->set_message('chk_attachment','Attachment allowed only csv');
return false;
}
}
{
$this->form_validation->set_message('chk_attachment','image field is required');
return false;
}
}
|
File uploading error in Codeigniter
Tag : php , By : Robin Buitenhuis
Date : March 29 2020, 07:55 AM
hop of those help? I am trying to upload an image in codeigniter. , Refer this code. this will surely work for you public function uploadImage() {
$this->load->helper(array('form', 'url'));
$config['upload_path'] = 'assets/images/b2bcategory';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '2024';
$config['max_height'] = '1768';
$config['width'] = 75;
$config['height'] = 50;
if (isset($_FILES['catimage']['name'])) {
$filename = "-" . $_FILES['catimage']['name'];
$config['file_name'] = substr(md5(time()), 0, 28) . $filename;
}
$config['overwrite'] = TRUE;
$config['remove_spaces'] = TRUE;
$field_name = "catimage";
$this->load->library('upload', $config);
if ($this->input->post('selsub')) {
if (!$this->upload->do_upload('catimage')) {
//no file uploaded or failed upload
$error = array('error' => $this->upload->display_errors());
} else {
$dat = array('upload_data' => $this->upload->data());
$this->resize($dat['upload_data']['full_path'], $dat['upload_data']['file_name']);
}
$ip = $_SERVER['REMOTE_ADDR'];
if (empty($dat['upload_data']['file_name'])) {
$catimage = '';
} else {
$catimage = $dat['upload_data']['file_name'];
}
$data = array(
'ctg_image' => $catimage,
'ctg_dated' => time()
);
$this->b2bcategory_model->form_insert($data);
}
}
|
Error in codeigniter while file uploading
Date : March 29 2020, 07:55 AM
To fix the issue you can do Are you using this code for multiple image upload? If you are using for multiple image then please load upload library $this->load->library('upload') outside loop. Please provide full code with method name if not multiple images.
|