form upload question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: form upload question (/showthread.php?tid=9416) |
form upload question - El Forum - 06-24-2008 [eluser]karloff[/eluser] I've edited this post as i solved the last problem, i can't pass the image path into the database. I'm sure it fairly simple but can't get the syntax correct i get this error Quote:A PHP Error was encountered not sure why it won't pass the image path to db, i followed the user guide (well i thought so, obviously i've gone wrong some where here is part of my controller Code: ............... Code: <?php $this->load->view('header'); ?> any help is much appreciated form upload question - El Forum - 06-26-2008 [eluser]karloff[/eluser] i've updated my post so it may be clearer if anyone can shine some light form upload question - El Forum - 06-26-2008 [eluser]Colin Williams[/eluser] Wow. Quote:Column count doesn’t match value count at row 1 Your column count is 4. Your values count is 5. Easy 'nuff. Also, this mishap can be avoiding by using the Active Record's insert() method rather than writing it out like that. And please don't say you didn't know you could do that. If nothing else, read through the Database Class part of the User Guide. Twice form upload question - El Forum - 06-26-2008 [eluser]karloff[/eluser] i appreciate the advice, still not sorted totally, but I'll go and have read and make sure i cover all the classes before asking a stupid question cheers for the heads up form upload question - El Forum - 06-26-2008 [eluser]Colin Williams[/eluser] Meh.. not a stupid question at all. Hope you get it working. form upload question - El Forum - 06-30-2008 [eluser]karloff[/eluser] right, back to this silly question, i can upload and the image and isert the image, however i get the following errors Quote:A PHP Error was encountered here is my controller Code: function work_insert() i also tried the $this->db->insert(); function but no joy form upload question - El Forum - 06-30-2008 [eluser]libnac[/eluser] In order to access file name you must try $_FILES['image']['name'] and in your form ensure to put on the property enctype='multipart/form-data'. Also you must try to call do_upload like this way: $config['upload_path'] = './images/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->upload->initialize($config); if ( ! $this->upload->do_upload('image')) ... <-- image is the field name in your form <input type='file' name='image'> form upload question - El Forum - 06-30-2008 [eluser]Colin Williams[/eluser] Quote:and in your form ensure to put on the property enctype=’multipart/form-data’. I bet this is the problem. Get to know your PHP errors. Undefined index means an array index was called upon but it did not exist. So, if CI tries to hit $_FILES['image'] and $_FILES['image'] does not exist, BAM!! Error on your ass. form upload question - El Forum - 07-01-2008 [eluser]karloff[/eluser] manage to get it working by passing 'userfile' => $data['upload_data']['file_name'], to the $data array. didn't need to set if ( ! $this->upload->do_upload(’image’)) as do_upload retrieves the value of userfile by default if no parameters are passed in also realised there was no need to post the userfile to a variable much to learn for me, cheers guys form upload question - El Forum - 07-02-2008 [eluser]charlie spider[/eluser] another way is to just always name your form's file input field 'userfile' since that's what php expects it to be |