<bdo id='Tq0lp'></bdo><ul id='Tq0lp'></ul>
  1. <small id='Tq0lp'></small><noframes id='Tq0lp'>

    1. <tfoot id='Tq0lp'></tfoot>
    2. <legend id='Tq0lp'><style id='Tq0lp'><dir id='Tq0lp'><q id='Tq0lp'></q></dir></style></legend>
      <i id='Tq0lp'><tr id='Tq0lp'><dt id='Tq0lp'><q id='Tq0lp'><span id='Tq0lp'><b id='Tq0lp'><form id='Tq0lp'><ins id='Tq0lp'></ins><ul id='Tq0lp'></ul><sub id='Tq0lp'></sub></form><legend id='Tq0lp'></legend><bdo id='Tq0lp'><pre id='Tq0lp'><center id='Tq0lp'></center></pre></bdo></b><th id='Tq0lp'></th></span></q></dt></tr></i><div id='Tq0lp'><tfoot id='Tq0lp'></tfoot><dl id='Tq0lp'><fieldset id='Tq0lp'></fieldset></dl></div>

      CodeIgniter - 通过表单上传图像,将图像的位置存储在数据库中

      CodeIgniter - Uploading an Image through a form, store the location of the image in database(CodeIgniter - 通过表单上传图像,将图像的位置存储在数据库中)
      • <i id='ofKK8'><tr id='ofKK8'><dt id='ofKK8'><q id='ofKK8'><span id='ofKK8'><b id='ofKK8'><form id='ofKK8'><ins id='ofKK8'></ins><ul id='ofKK8'></ul><sub id='ofKK8'></sub></form><legend id='ofKK8'></legend><bdo id='ofKK8'><pre id='ofKK8'><center id='ofKK8'></center></pre></bdo></b><th id='ofKK8'></th></span></q></dt></tr></i><div id='ofKK8'><tfoot id='ofKK8'></tfoot><dl id='ofKK8'><fieldset id='ofKK8'></fieldset></dl></div>
        <tfoot id='ofKK8'></tfoot>
          <bdo id='ofKK8'></bdo><ul id='ofKK8'></ul>

            <tbody id='ofKK8'></tbody>
          • <legend id='ofKK8'><style id='ofKK8'><dir id='ofKK8'><q id='ofKK8'></q></dir></style></legend>

                <small id='ofKK8'></small><noframes id='ofKK8'>

              1. 本文介绍了CodeIgniter - 通过表单上传图像,将图像的位置存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试通过表单将图像上传到我的网站,但是将图像的位置存储在数据库中(而不是让数据库陷入困境)效率更高.

                I'm trying to upload an image to my site through a form, however it's much more efficient to (rather than bog down the database) just store the location of the image in the database.

                我的表格有问题,真的不知道该去哪里:

                I'm having trouble with my form and really don't know where to go:

                <?=form_open('bro/submit_new');?>
                 //other form data
                 Image: <input type="file" name="image" size="20" /> <br>
                 <input type="submit" value="Submit" />
                </form>
                

                现在表单本身工作正常,问题是它试图将图像存储到数据库字段图像"(TEXT 类型)中.告诉它只存储文件并将文件位置存储在图像"字段中的最简单方法是什么?(我告诉它通过控制器上传文件的位置).

                Now the form itself works fine, the problem is that it's trying to store the image into the database field 'image' (which is type TEXT). What's the easiest way to tell it to just store the file, and give the file location to store in the 'image' field? (I tell it where to upload the file via the controller).

                谢谢

                控制器代码(本部分):

                controller code (for this part):

                function submit_new(){
                    $config['upload_path'] = './images/';
                    $config['allowed_types'] = 'gif|jpg|png';
                    $config['max_size'] = '2000';
                    $config['max_width']  = '1024';
                    $config['max_height']  = '768';     
                    $this->load->library('upload', $config);
                
                    $this->db->insert('post', $_POST);
                
                    redirect('bro');
                }
                

                推荐答案

                CodeIgniter 的文件上传类会帮你搞定.他们的用户指南中的条目解释得很好,所以我要指向你那里.

                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.

                基本上你只需要修改他们在那里的控制器,包括一些你将文件 URL 放入数据库的位置,你可以通过使用 $this->upload->data() 并提取[full_path] 从结果数组中提取,然后将其发送到处理数据库输入的模型.

                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.

                这篇关于CodeIgniter - 通过表单上传图像,将图像的位置存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
              2. <legend id='mrv1n'><style id='mrv1n'><dir id='mrv1n'><q id='mrv1n'></q></dir></style></legend>

                  <bdo id='mrv1n'></bdo><ul id='mrv1n'></ul>
                • <small id='mrv1n'></small><noframes id='mrv1n'>

                • <tfoot id='mrv1n'></tfoot>
                  1. <i id='mrv1n'><tr id='mrv1n'><dt id='mrv1n'><q id='mrv1n'><span id='mrv1n'><b id='mrv1n'><form id='mrv1n'><ins id='mrv1n'></ins><ul id='mrv1n'></ul><sub id='mrv1n'></sub></form><legend id='mrv1n'></legend><bdo id='mrv1n'><pre id='mrv1n'><center id='mrv1n'></center></pre></bdo></b><th id='mrv1n'></th></span></q></dt></tr></i><div id='mrv1n'><tfoot id='mrv1n'></tfoot><dl id='mrv1n'><fieldset id='mrv1n'></fieldset></dl></div>

                        <tbody id='mrv1n'></tbody>