how to upload image and create item to database in one button |
help me please
this is my controllers create item PHP Code: function create_item() and this my controller upload PHP Code: public function do_upload() and this my view PHP Code: <?php echo validation_errors(); ?>
For one you do not want to save images to the database, save them to a directory and then save the path and filename to the database.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Before redirect('home'), insert the code that inserts the item (title, path, size etc.) into the table in your database. That way, it's assured that the upload itself was successful and the image exists. If you insert the item into the table before do_upload(), then you never know...
(06-17-2016, 03:57 AM)Wouter60 Wrote: Before redirect('home'), insert the code that inserts the item (title, path, size etc.) into the table in your database. That way, it's assured that the upload itself was successful and the image exists. If you insert the item into the table before do_upload(), then you never know... can you give me example for my problem ?
If you must save it to the database the image table field must be a BLOB type
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(06-18-2016, 02:45 AM)InsiteFX Wrote: If you must save it to the database the image table field must be a BLOB type i try to post in my database with field name : name, price, image, category and brand. but in my view form. i want do that in one submit buttom. and my problem is in upload image in upload directory. until now i cannot fix my problem. can you give me emaple for that ? and what is Blob type ? please help me sorry im newbe. and sorry for my bad english
fian rahardian
submit form with enctype="multipart/form-data" upload image with CI library upload and get upload data and store your other data in DB with uploaded file name
Usually on this board or on stackoverflow - you will get helpful responses if you have a specific error that you are trying to work through. Otherwise you are asking people to create an application for you and that usually does not happen.
So first - work through some tutorials and build. https://www.google.com/#q=codeigniter+im...d+tutorial
|
Welcome Guest, Not a member yet? Register Sign In |