在 codeigniter 中上传图像并插入文本
我正在尝试上传带有标题和描述的图像以及图像上传。我的图像上传和文本输入是分开工作的,文本和图像路径也被插入到数据库中,但我仍然无法弄清楚如何将两者结合起来,
我使用了 http://codeigniter.com/user_guide/libraries/file_uploading.html
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
有人可以告诉我如何在图像中插入一些文本字段将表单上传到sql数据库?
im trying to upload an image with a title and description along with the image upload. My image upload and text inputs work separately and the text and the image path is also inserted to the DB but i still cant figure how to combine both
i used the guides given in http://codeigniter.com/user_guide/libraries/file_uploading.html
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
can someone tell me how can i insert some text fields along with the image upload form to a sql database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,只需以相同的形式输入图像上传输入,例如:
并在控制器中添加 POST 读取:
您还需要制作一个适当的模型来将数据输入数据库中。
Basically, just put the image upload input in the same form, like:
And add in the controller the POST reading:
You will also need to make a proper model to input the data in the database.