Store Image path into DB |
[eluser]Shella[/eluser]
Hi, should be a pretty easy thing to do but is couple of hours I'm trying invane. In PHP it's pretty easy when you upload a file you have to catch the $_FILES data but here...? The point is that I have no error back in the select I just have an empty value. I guess is the model to understand. VIEW Code: [...] CONTROLLER Code: [...] MODEL Code: function create_article() Thanks for help
[eluser]NotDior[/eluser]
Check out the documentation for the file uploader class (assuming that's what your using). $this->upload->data() - will give you an array of file information your looking for and you can pass to your model. http://ellislab.com/codeigniter/user-gui...ading.html
[eluser]Shella[/eluser]
Thanks for reply. Unfortunately this is exactly my drama. If I use this code: Code: $new_article_insert_data = array( I get this error: Severity: Notice Message: Undefined property: CI_Upload::$data Filename: models/articles_model.php ...and if I use this: Code: $new_article_insert_data = array( I get this error: Severity: Notice Message: Array to string conversion Filename: mysql/mysql_driver.php This last is trying to write a general "array" into the database: Code: INSERT INTO `articles` (`title`, `content`, `image`, `id_category`, `created_on`) VALUES ('Post Title', '\r\n Example data', Array, '44', '2012-06-14 15:19:28') ...I feel so dumb.. but I can't understand this logic...
[eluser]NotDior[/eluser]
Shella, Sorry for the delay on getting back to you. It appears to me that part of the problem might be that you are trying to grab your upload data directly in the model rather than throwing that data into an array() in your controller and then passing that array to your model. See if something like this gets you down the road. CONTROLLER Code: [...] MODEL Code: function create_article($aData) Lastly in your last post/example it looks like $this->upload->data('file_name') is an array for some reason.
[eluser]Shella[/eluser]
Hi! So sorry I'm just back to my desk today and I'm bit late too! I solved the issue. My problem was about a misunderstanding using this MVC way. I'm pretty new with this programming technic. I thank you very much for your help. Have a good day! |
Welcome Guest, Not a member yet? Register Sign In |