如何在上传pdf文件时将大小增加到5 MB以上

时间:2018-01-02 06:17:40

标签: codeigniter pdf

在上传pdf文件时我想增加5 mb以上的大小,下面的代码只允许2 mb如何增加5 mb以上的大小请帮我任何一个并解决我的问题

public function question_upload() {           
    $this->form_validation->set_rules('examname', 'Select Exam Type', 'required');
    $this->form_validation->set_rules('assignment', 'Subject Name', 'required');
    $this->form_validation->set_rules('question', 'Content Name', 'required');
    $this->form_validation->set_rules('subcontent', 'Sub Content Name', 'required');
    if (empty($_FILES['picture']['name'])) {
    $this->form_validation->set_rules('picture', 'Pdf', 'required');
    }
    if ($this->form_validation->run() == FALSE) {
    $data['h'] = $this->Faculty_Model->faculty_QuestionDisplay();
    $data['studentAnswer'] = $this->Faculty_Model->student_Question();
    $this->load->view('index1', $data);
    } else {
    if (!empty($_FILES['picture']['name']))         
    $config['upload_path'] = 'uploads/files/';
    $config['allowed_types'] = 'jpg|jpeg|png|gif|pdf';
    $config['file_name'] = $_FILES['picture']['name'];   
    $this->load->library('upload', $config);
    $this->upload->initialize($config);
    if ($this->upload->do_upload('picture')) {
    $uploadData = $this->upload->data();
    $picture = $uploadData['file_name'];
    } else {
    $picture = '';
    }
    } else {
    $picture = '';
    }
    $userData = array(
    'datee' => $this->input->post('datee'),
    'examname' => $this->input->post('examname'),
    'assignment_name' => $this->input->post('assignment'),
    'question   ' => $this->input->post('question'),
    'subcontent' => $this->input->post('subcontent'),
    'pdffile' => $picture
    );
    $this->Faculty_Model->faculty_Questioninsert($userData);

    $this->session->set_flashdata('success_msg', 'User data have been added successfully.');
    redirect('welcome/index1');
    }
    }

2 个答案:

答案 0 :(得分:0)

你需要在你的php.ini中设置upload_max_filesize的值:

upload_max_filesize = 2M defalt upload_max_filesize = 5M

          (or)

你需要在代码config.php中添加以下行(root path public_html / application / config)

ini_set('upload_max_filesize','5M');

          (or)

您需要添加以下代码行.htaccess php_value upload_max_filesize 5M

答案 1 :(得分:0)

place the constructor inside or class inside it will work

class Home_model extends CI_Model {

/**
 * @return void
 * */
public function __construct() {
    parent::__construct();
    $this->load->helper("security");       
    ini_set('upload_max_filesize', '5M');
}