How to get file name to be inserted to database ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to get file name to be inserted to database ? (/showthread.php?tid=27552) Pages:
1
2
|
How to get file name to be inserted to database ? - El Forum - 02-14-2010 [eluser]dimasVS[/eluser] Hi all,, I want to know, how to get the name of file that had been encrypted ??? I'll use that name to be inserted into database. this is my script : function do_upload(){ $n = rand(0,100000); $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $config['encrypt_name'] = "$n"; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('admin/employeeAdd', $error); } else { $data = array('upload_data' => $this->upload->data()); echo "Register Successfull<br />"; echo anchor(base_url().'index.php/admin/employee', 'Back'); } } how to get the value of $config['encrypt_name'] or $config['file_name'] ? and how to throw it to models ? thanks so much How to get file name to be inserted to database ? - El Forum - 02-14-2010 [eluser]Derek Allard[/eluser] Look for $this->upload->data() on file uploading doc page. How to get file name to be inserted to database ? - El Forum - 02-14-2010 [eluser]dimasVS[/eluser] sorry but,, how to get the value of that array ?? I tried to use echo $this->upload->data('file_name'); but didn't give me the name of file. thanks Derek, How to get file name to be inserted to database ? - El Forum - 02-14-2010 [eluser]ciGR[/eluser] Hi, try this Code: $img_data = $this->upload->data(); Also I see in your code the Code: echo anchor(base_url().‘index.php/admin/employee’, ‘Back’); you can write Code: echo anchor('admin/employee','Back'); Hope to help you. How to get file name to be inserted to database ? - El Forum - 02-15-2010 [eluser]dimasVS[/eluser] wow... thank you so much cigr... now, I got that value... but now, how to send $file_name value to models ??? How to get file name to be inserted to database ? - El Forum - 02-15-2010 [eluser]Derek Allard[/eluser] Take a read through the userguide again dimasVS, I think it'll be helpful. After you've read it, if things still aren't clear, could you show me the code you'd use to pass $name into the "new_person()" function of the following model? Notice that I'm taking File Uploading completely out of the equation. Code: $this->load->model('people_model'); How to get file name to be inserted to database ? - El Forum - 02-15-2010 [eluser]ciGR[/eluser] Have you create the model? In model you must have create the appropriate functions. For example, Code: class Model_name extends Model { and in your controller after successful image upload you must load the model and call the function with the image name like the argument Code: $this->load->model('Model_name'); How to get file name to be inserted to database ? - El Forum - 02-15-2010 [eluser]Derek Allard[/eluser] Right, exactly. So back to your question Quote:how to send $file_name value to models ???The exact same way. Code: $this->load->model('Model_name'); How to get file name to be inserted to database ? - El Forum - 02-15-2010 [eluser]dimasVS[/eluser] [quote author="ciGR" date="1266262210"]Have you create the model? In model you must have create the appropriate functions. For example, Code: class Model_name extends Model { and in your controller after successful image upload you must load the model and call the function with the image name like the argument Code: $this->load->model('Model_name'); Ok,, :-) I got the value and successfully inserted to database... How to get file name to be inserted to database ? - El Forum - 02-15-2010 [eluser]dimasVS[/eluser] [quote author="Derek Allard" date="1266262377"]Right, exactly. So back to your question Quote:how to send $file_name value to models ???The exact same way. Code: $this->load->model('Model_name'); Thanks Derek,, it really help me... Now I could get the $file_name value and successfully inserted.. hmm,, once more.. :-) how if it's not only $file_name... for example I wanna throw the values of $file_name, $file_type, $username ??? and how to get the value of each variable in models... Now, I usually create session first... |