@lizzie
To update a PDF file and an image file in CodeIgniter, you can use the following steps:
Here is an example code snippet to update a PDF file and an image file in CodeIgniter:
Controller:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
public function update_files() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'pdf|jpeg|jpg|png'; $this->load->library('upload', $config); if ($this->upload->do_upload('pdf_file')) { $pdf_data = $this->upload->data(); $pdf_path = 'uploads/' . $pdf_data['file_name']; } if ($this->upload->do_upload('image_file')) { $image_data = $this->upload->data(); $image_path = 'uploads/' . $image_data['file_name']; } // Update file paths in the database $this->your_model->update_files($pdf_path, $image_path); // Display success message $this->session->set_flashdata('success', 'Files updated successfully'); redirect('your_controller/your_method'); } |
View:
1 2 3 4 5 |
<?php echo form_open_multipart('your_controller/update_files'); ?> <input type="file" name="pdf_file"> <input type="file" name="image_file"> <button type="submit">Update Files</button> <?php echo form_close(); ?> |
This is just an example to get you started. Make sure to customize the code according to your project requirements and file structure.