Postingan lainnya
Gagal upload image
Halo, saya mau bertanya bagaimana cara agar upload gambar tidak gagal dengan menggunakan CI. Saya sudah mencoba var_dump pada display error nya dan hasilnya adalah upload path tidak valid, padahal saya sudah cek dan memastikan path yg dimasukkan sudah benar. Berikut saya sertakan kode dari controller submit
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Weeklysurvey extends CI_Controller
{
# CONSTRUCT
function __construct()
{
parent::__construct();
$this->load->model('weekly_survey_model');
$this->load->helper('asset_helper');
$this->load->library('uploader');
$this->no_cache();
}
# CLEAR CACHE
protected function no_cache()
{
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0',false);
header('Pragma: no-cache');
}
function weekly_survey_input()
{
if($this->input->post('go_submit'))
{
#upload image
$config['upload_path'] = './uploads/surveyreport/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('upload1'))
{
$error = $this->upload->display_errors();
//var_dump($this->upload->display_errors());
} else {
$result = $this->upload->data();
}
#display form
$this->load->view('weekly_survey_input',$data);
}
else{
$this->load->view('weekly_survey_input',$data);
}
}
}
?>
berikut adalah viewnya :
<div class="row">
<div class="col-md-12" style="background-color:#fff;padding-top:20px;padding-bottom:20px;">
<form method="post" action="<?php echo base_url()."surveyreport/weeklysurvey/weekly_survey_input.html"; ?>" enctype="multipart/form-data">
<div class="row">
<div class="col-md-12" class="form_group03" style="display:inline-block;margin-bottom:30px;">
<div class ="col-md-6" class="image_dokumentasi">
<div class="col-md-12">
<h3 class="title02">Dokumentasi</h3>
</div>
<div>
<input name="upload1" type="file" class="form-control">
</div>
</div><!--end of image_dokumentasi-->
</div>
<div class="col-md-12" style="display:inline-block;margin-bottom:5px;margin-top:50px;text-align:center;">
<input type="submit" value="Simpan" name="go_submit" class="btn btn-success">
</div>
</div>
</form>
</div><!-- END COL-MD-12 -->
</div>
0
1 Jawaban:
Jawaban Terpilih
apakah permisssion dari folder nya sudah diatur, agar writeable?
0
Tanggapan
Terima kasih. Saya cek foldernya ternyata settingan writeablenya masih belum aktif, setelah saya aktifkan, proses upload bisa berjalan lancar