title: CodeIgniter Upload Class Allowed File Types
body: <p>I'm using Codeigniter Upload Class but I have a problem with allowed file types. I need to allow only pdf files to upload but any kind of file can be upload. Here is my code;</p>
  
  <p>model (muser.php);</p>
  
  <pre><code>function cv_ekle()
  {
      $config['upload_path'] = 'uploads/cv';
      $config['allowed_types'] = 'pdf';
      $config['max_size'] = '0';
      $config['max_width']  = '0';
      $config['max_height']  = '0';
      $this-&gt;load-&gt;library('upload', $config);
      $this-&gt;upload-&gt;do_upload();
      $data = $this-&gt;upload-&gt;data();
  
      $this-&gt;load-&gt;library('upload', $config);
      $upload_data = $this-&gt;upload-&gt;data(); //Returns array of containing all of the data related to the file you uploaded.
      $file_name = $upload_data['file_name'];
      $data = array
          (
              'userid' =&gt; $this-&gt;session-&gt;userdata('id'),
              'kullanici' =&gt; $this-&gt;session-&gt;userdata('isim'),
              'kategori' =&gt; $this-&gt;input-&gt;post('kategori'),
              'tarih' =&gt; time(),
              'dosya' =&gt; $file_name
          );
      if($this-&gt;db-&gt;insert('cv', $data))
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  </code></pre>
  
  <p>controller (cv.php);</p>
  
  <pre><code>function cv_ekle()
  {
      if($this-&gt;muser-&gt;cv_ekle())
      {
          $this-&gt;session-&gt;set_flashdata('ok', 'CV başarıyla gönderildi!');
          redirect('cv');
      }
      else
      {
          $this-&gt;session-&gt;set_flashdata('hata', 'Sadece PDF, Excel ya da Word formatında yükleme yapabilirsiniz!');
          redirect('cv');
      }
  }
  </code></pre>
  
  <p>view (cv.php);</p>
  
  <pre><code>&lt;form method="post" action="&lt;?php echo site_url('cv/cv_ekle'); ?&gt;" class="login" enctype="multipart/form-data"&gt;
                      &lt;div class="controls"&gt;
                          &lt;label for="email"&gt;Dosya: &lt;span class="text-error"&gt;*&lt;/span&gt;&lt;/label&gt;
                          &lt;input type="file" id="pass" class="input-block-level" name="userfile" &gt;
                      &lt;/div&gt;
                      &lt;div class="controls"&gt;
                          &lt;label for="email"&gt;Kategori: &lt;span class="text-error"&gt;*&lt;/span&gt;&lt;/label&gt;
                          &lt;select class="input-block-level" name="kategori"&gt;
                              &lt;?php foreach($kategoriler as $kat) { ?&gt;
                                  &lt;option value="&lt;?php echo $kat['isim']; ?&gt;"&gt;&lt;?php echo $kat['isim']; ?&gt;&lt;/option&gt;
                              &lt;?php } ?&gt;
                          &lt;/select&gt;
                      &lt;/div&gt;
                      &lt;div class="controls"&gt;
  
                          &lt;button type="submit" class="btn btn-primary"&gt;CV Yükle&lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>Thanks in advance!</p>