Welcome Guest, Not a member yet? Register   Sign In
unable to upload any other type of files.
#1

[eluser]Ram Krishna[/eluser]
i have written a code for uploading the files like images,pdf,doc,docx etc.But i am able to upload only images. my controller code is below..
Code:
<?php

class Quote extends CI_Controller {

function __construct()
{
  parent::__construct();
  $this->load->helper(array('form', 'url'));
  
}

function index()
{
  $this->load->view('request_quote_form');
}

function do_upload()
{
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png|doc|docx|jpeg|pdf|txt|ppt|zip|php';
        $config['max_size']='1024*20';
  

  $this->load->library('upload', $config);

  $this->upload->do_upload();
     $data = $this->upload->data();
        $file_name=$data['file_name'];

      

  
}
}
?>
.
#2

[eluser]vitoco[/eluser]
Some hosting services doesn't allow uploading some file formats, in that case, the request will not even enter the controller, if that's not the case, i'll echo the raw data from the $_FILES array to check that the file MIME it's defined in config/mimes.php

Code:
function do_upload()
{
  echo '<pre>'.print_r( $_FILES , true ).'</pre>'; // print all uploaded files
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png|doc|docx|jpeg|pdf|txt|ppt|zip|php';
        $config['max_size']='1024*20';
  

  $this->load->library('upload', $config);

  $this->upload->do_upload();
     $data = $this->upload->data();
        $file_name=$data['file_name'];
  
}

Saludos




Theme © iAndrew 2016 - Forum software by © MyBB