CodeIgniter - Uploading an Image through a form, store the location of the image in database

大城市里の小女人 提交于 2019-11-30 10:10:49

CodeIgniter's file uploading class will do this for you. The entry in their user guide explains as well as I could, so I'm going to point you there.

Essentially you'd just need to modify the controller that they have there to include a bit where you put the file URL in the database, which you can accomplish easily by using $this->upload->data() and extracting [full_path] from the resulting array, and then sending it to a model which handles the database input.

use form_open_multipart() not form_open()

use the model pages to upload data to database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!