[eluser]kakap[/eluser]
this my source:
controller 'upload'
Code:
function uploadfile(){
//upload file ke server
if ($this->input->post('name')){
this->MDownload->addFile();
$this->session->set_flashdata('message', 'File berhasil diUpload');
redirect('admin/download/', 'refresh');
} else{
$data['path'] = 'Upload';
$data['title'] = 'Admin | Upload file';
$this->load->vars($data);
$this->load->view('upload');
}
model 'mupload'
Code:
function addFile(){
if ($_FILES){
$config['upload_path'] = './files/';
$config['allowed_types'] = 'jpg|xls|png|bmp|gif|doc|rtf|txt|zip|rar|pdf|ppt';
$config['max_size'] = '20000';
$config['remove_spaces'] = true;
$config['overwrite'] = false;
$this->load->library('upload', $config);
if (strlen($_FILES['file']['name'])){
if (!$this->upload->do_upload('file')){
$this->upload->display_errors();
exit();
}
$file = $this->upload->data();
$data = array(
'name' => $_POST['name'],
'date' => $_POST['date'],
'status' => $_POST['status'],
'size' => $file['file_size'],
'file' => 'files/'.$file['file_name']
);
$this->db->insert('download', $data);
}
}
}
view 'upload'
Code:
<?php
$data = array('class' => 'jNice');
echo form_open_multipart('admin/download/uploadfile', $data);
echo "<fieldset>";
echo "<p><label for='name'>Judul</label>";
$data = array('name' => 'name', 'id' => 'name', 'class' => 'text-long');
echo form_input($data)."</p>";
echo "<p><label for='date'>Tanggal</label>";
$data = array('name' => 'date', 'id' => 'date', 'class' => 'text-medium', 'value' => date("j-M-Y g:i a"));
echo form_input($data)."</p>";
echo "<p><label for='status'>Status</label>";
$option = array('active' => 'active', 'inactive' => 'inactive');
echo form_dropdown('status', $option)."</p>";
echo "<p><label for='file'>File</label>";
$data = array('name' => 'file', 'id' => 'file');
echo form_upload($data)."
<span>ekstensi file: <em>jpg, gif, png, bmp, xls, doc, rtf, txt, zip, rar, pdf, ppt</em></span><br />
<span>Maksimal ukuran file : 20mb</span>
</p>";
echo form_submit('submit', 'Simpan');
echo "</fieldset>";
echo form_close();
?>
when I upload image file such *jpg, *gif, *png it worked, but when I tried to upload another file type such *rar, *doc, *etc.. its failed.
is something I missed???
I use CI 1.7.2
thankyou for Ur appresiation