<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 - 通过表单上传图像,将图像的位置存储在数据库中

      时间:2023-12-01
      • <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 - 通过表单上传图像,将图像的位置存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Laravel 文件不存在 - 文件上传 下一篇:推特 API -&gt;用 php 更新个人资料 bg 图像

                相关文章

              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>
              3. <small id='mrv1n'></small><noframes id='mrv1n'>

              4. <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>