Need example for record add/edit with image upload |
[eluser]Frank Rocco[/eluser]
Hello, I have a table with: Item(int), Item_name(varchar 25), Price (decimal 9.2), small_image(varchar 50), large_image(varchar 50) I need to add/edit/delete record and allow image upload and save path in the table. now quite sure how to handle this is the controller. Thanks Frank
[eluser]mi6crazyheart[/eluser]
Writing SQL query in controller is not a good place at all. For that try to use MODEL function. You can build separate model function for each job(insert/Update/delete). For making sql query u can use CI's active record class: http://ellislab.com/codeigniter/user-gui...ecord.html
[eluser]Frank Rocco[/eluser]
Sorry, I am asking on the logic to upload and save the path when the user saves the record. All DB work will be down in the model. Controller: 1. validate 2. any errors 3. upload 4. any errors 5. save Not sure how to code the controller to do this.
[eluser]Frank Rocco[/eluser]
Code: if ($this->form_validation->run() == FALSE) Would this be the best approach?
[eluser]mi6crazyheart[/eluser]
@Frank Rocco You can go by these steps: [1] upload the image by http://ellislab.com/codeigniter/user-gui...ading.html [2] Save the image path in variable & pass that to a model function [3] Now, in the model function save that image path in to a respective table.
|
Welcome Guest, Not a member yet? Register Sign In |