php - CodeIgniter Upload Library not returning file extension -


for reason stack overflow removing top line, start saying hi , thank looking.

just title says code igniter isn't returning files extension type. have tried

$upload_data = $this->upload->data();      $ext = $upload_data['file_ext'];  

but returns empty string.

if var dump $upload_data get, can see has no file type. bug? missing something? else works intended except can't retrieve file extension in order put in db.

array (size=14)   'file_name' => string '123456' (length=6)   'file_type' => string '' (length=0)   'file_path' => string 'uploads/' (length=8)   'full_path' => string 'uploads/123456' (length=14)   'raw_name' => string '123456' (length=6)   'orig_name' => string '' (length=0)   'client_name' => string '' (length=0)   'file_ext' => string '' (length=0)   'file_size' => string '' (length=0)   'is_image' => boolean false   'image_width' => string '' (length=0)   'image_height' => string '' (length=0)   'image_type' => string '' (length=0)   'image_size_str' => string '' (length=0) 

file renaming :

     /altering file name user input         $str = $this->input->post('filename');         $config['file_name'] = $str;    //adding name db     $imagename = $str;      $this->image_model->addimage($imagename, $imageurl); 

to clarify query, want able retrieve file extension can store uri(url?) in database can populate dropdown images in database already.

you can use pathinfo( $imagename, pathinfo_extension ) extention of file regardless of using lib.

example :

$link = 'base.mini.css';  if( pathinfo( $link, pathinfo_extension ) == 'css' ){  echo "css file";  }else{  echo "file ext :".pathinfo( $link, pathinfo_extension ); } 

yet please note in example provided file name not contain , extension ! normal codeigniter not figure out extension file !


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -