Welcome Guest, Not a member yet? Register   Sign In
failed upload file save image file types

this my source:
controller 'upload'
function uploadfile(){
        //upload file ke server
        if ($this->input->post('name')){
            $this->session->set_flashdata('message', 'File berhasil diUpload');
            redirect('admin/download/', 'refresh');
        } else{
            $data['path'] = 'Upload';
            $data['title'] = 'Admin | Upload file';

model 'mupload'
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')){
                $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'
$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>

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

I am having the same trouble with the following file types. Won't handle any but the first three:

$config['allowed_types'] = 'gif|jpg|png|pdf|txt|rtf|doc|docx|xls|ppt|jpeg|bmp|zip';

did anyone get the bottom of this? i'm currently having the same issue as well.

Yes, it is a bug that hasn't been fixed (or documented in the User Guide), but the fix is pretty easy. You have to list your document types BEFORE your graphic types:


It's be great if they just added this to the User Guide.

Thanks timj,

i've got side tracked at the moment but its good to answer for when i get back to it!

it does not work for me. how can we fix this problem any suggestions?

[eluser]maria clara[/eluser]
maybe you have to check your mimes.php look at it in your system/application/config/.

Theme © iAndrew 2016 - Forum software by © MyBB