Weird problem with POST and the upload class |
[eluser]Cryorus[/eluser]
Hi everyone. Well, im a newbie learning this thing, pretty cool indeed. The site: http://cryorus.ignavus.org/gedn/ In my admin panel, im trying to add news to the database with an image, submitting the info to my database. Submitting it was perfect till i added the file upload class, it uploads perfectly and i can still insert the info to the database, everything but the 'img' field. I did some debug and $this->input->post('img'), is empty. Now im insering to the database: "/resources/images/" Im using dwoo for templates, so im not using any php code in my view files. Here is my code. Controller: Code: function add() { View: Code: <div id="news"> Im pretty sure we dont need to know any of the other code. Thanks in advance. Edit: if in wrong section, please move, sorry.
[eluser]Cryorus[/eluser]
This isnt an easy thing as it looks? Edit: Ok, i added the rule for the img field "required" and when i try to submit, i get an error saying that an image is required, so... something is removing the content inside my 'img' field. Anyone? Really thanks in advance, this is driving me crazy.
[eluser]deczo[/eluser]
Hi there, i assume you want to insert into db uploaded file location, right? So you can't use: Code: 'img' => '/resources/images/' . $this->input->post('img'), Anyway in CI just use upload data helper, part of the upload library: after upload add: Code: $uploadDataArray = $this->upload->data(); Code: 'img' => '/resources/images/' . $uploadDataArray['file_name'], You can use $uploadDataArray['full_path'] instead, for details check http://ellislab.com/codeigniter/user-gui...ading.html
[eluser]Cryorus[/eluser]
Thank you, already did it this way, but i didnt know why $post didnt work. Thanks again. |
Welcome Guest, Not a member yet? Register Sign In |