Postingan lainnya
CI3 Data Post file dan text kosong saat di debug di OS Ubuntu
Selamat pagi, mohon bantuan nya,
saya buat fungsi upload file di CI3 dengan server ubuntu, saat upload image dan text itu berjalan dengan baik, tapi ketika saya upload file mp4 itu data post nya kosong, tapi ini fungsi image sama video berbeda file php yah. tapi saya coba di os windows bisa 22 nya. saya sudah setting akses folder chmod 777, seting max size di php.ini di ubuntu masih kosong data post video nya. ada yang tau kah kenapa atau ada setingan lain di server ubuntu nya
view
<div class="card">
<div class="card-header">
<a>Custom background video website</a>
</div>
<div class="card-body" style="color: black;">
<h5 class="card-title"></h5>
<div style="color:red">
<?php echo validation_errors(); ?>
<?php if(isset($error)){print $error;}?>
</div>
<?php echo form_open_multipart('upload_file/file_data');?>
<div class="mb-3">
<label for="formFile" class="form-label">Name</label>
<input type="text" class="form-control" name="pic_title" value="<?= set_value('pic_title'); ?>" id="pic_title">
</div>
<div class="mb-3">
<label for="formFile" class="form-label">Upload File</label>
<input type="file" name="pic_file" class="form-control" id="pic_file">
</div>
<br>
<a href="<?=base_url();?>" class="btn btn-warning">Back</a>
<button type="submit" name="proses" class="btn btn-success">Submit</button>
</div>
</div>
<br>
controller
public function file_data(){
var_dump($_POST);
// validate the form data
//
// $this->load->library('upload');
// if(isset($_POST['proses'])){
// $this->form_validation->set_rules('pic_title', 'Video Title', 'required');
// if ($this->form_validation->run() == FALSE){
// $this->load->view('admins/header');
// $this->load->view('admins/upload_form');
// $this->load->view('admins/footer');
// }else{
// $data['pic_title'] = $this->input->post('pic_title', TRUE);
// $config['upload_path'] = './upload/';
// $config['allowed_types'] = 'mp4|mov';
// $config['max_size'] = 90000;
// $config['max_width'] = 1920;
// $config['max_height'] = 1080;
// $this->load->library('upload', $config);
// if ( ! $this->upload->do_upload('pic_file')){
// $error = array('error' => $this->upload->display_errors());
// // $this->load->view('upload_form', $error);
// $this->load->view('admins/header');
// $this->load->view('admins/upload_form', $error);
// $this->load->view('admins/footer');
// }else{
// $upload_data = $this->upload->data();
// $data['pic_file'] = $upload_data['file_name'];
// $this->model_pic->store_pic_data($data);
// redirect('admin/heading');
// }
// }
// }else{
// var_dump('error');
// }
}
1 Jawaban:
Jawaban Terpilih
<div>Based on your code, it seems that you are trying to upload a file with the name "pic_file" using the CodeIgniter upload library. However, you mentioned that when you try to upload an mp4 file, the POST data is empty.<br><br></div><div><br>This could be due to the default value of the <strong>post_max_size</strong> configuration directive in your php.ini file on your Ubuntu server being set to a lower value than the size of the mp4 file you are trying to upload. You can check this by creating a PHP file on your server with the following code:<br><br></div><pre><?php phpinfo();</pre><div><br><br>This will output the PHP information on your server, and you can check the value of the <strong>post_max_size</strong> directive.<br><br></div><div><br>To fix this issue, you can increase the value of <strong>post_max_size</strong> in your php.ini file or in your .htaccess file. Here is an example of setting it to 50MB in your .htaccess file:<br><br></div><pre>php_value post_max_size 50M</pre><div><br><br>Additionally, you may want to check the value of <strong>upload_max_filesize</strong> in your php.ini file and set it to a value greater than the size of your mp4 file. This configuration directive sets the maximum size of an uploaded file.<br><br></div><div><br>If you have checked and adjusted these settings, and you are still unable to upload mp4 files, you may want to check the server logs for any error messages or try to debug your code further to see if there are any other issues with your upload function</div>
Tanggapan
thanks for the answer.