php - Codeigniter file path is not stored properly in database -
the file path of file i'm trying upload not stored properly.
my problem is, instead of storing path:
c:/xampp/htdocs/dev/csbrms/upload/file.xlsx
it stores:
c:/xampp/htdocs/dev/csbrms/upl
this code
view.php
<input type = "file" name = "userfile" id="userfile"/>
controller.php
$upload_data = $this->upload->data(); $file_name = $upload_data['file_name']; $data = array(... 'file_path' => $file_name, );
model.php
function add_records($data){ try { $sql = "call `sp_add_user_request`(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $result = $this->csbrms->query($sql,$data); // $data included 3 param , binding & query db $this->csbrms->close(); } catch (exception $e) { echo $e->getmessage(); } return $result; }
you using file_path store file info, whereas want use full_path include path , filename.
$file = $upload_data['full_path'];
you can see return fields helper function in docs here: http://www.codeigniter.com/user_guide/libraries/file_uploading.html#ci_upload::data
but here example return array fields can use:
array ( [file_name] => mypic.jpg [file_type] => image/jpeg [file_path] => /path/to/your/upload/ [full_path] => /path/to/your/upload/jpg.jpg [raw_name] => mypic [orig_name] => mypic.jpg [client_name] => mypic.jpg [file_ext] => .jpg [file_size] => 22.2 [is_image] => 1 [image_width] => 800 [image_height] => 600 [image_type] => jpeg [image_size_str] => width="800" height="200" )
hope helps,
paul.
Comments
Post a Comment