Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的MySQL插入图像post函数返回0_Php_Mysql_Codeigniter_Blob - Fatal编程技术网

php中的MySQL插入图像post函数返回0

php中的MySQL插入图像post函数返回0,php,mysql,codeigniter,blob,Php,Mysql,Codeigniter,Blob,我正在尝试为我的用户导入一个配置文件图片,并将其以blob格式插入数据库。但是当我运行代码并选择图像时,我得到的文件\u get\u contents()不能为空错误 我已经尝试了许多其他与这个问题相关的解决方案,但都没有成功 控制器: public function wijzigen() { $foto = $this->input->post($_FILES['profielfoto']['tmp_name']); $fotoContent = addslash

我正在尝试为我的用户导入一个配置文件图片,并将其以blob格式插入数据库。但是当我运行代码并选择图像时,我得到的文件\u get\u contents()不能为空错误

我已经尝试了许多其他与这个问题相关的解决方案,但都没有成功

控制器:

public function wijzigen()
{
    $foto = $this->input->post($_FILES['profielfoto']['tmp_name']);

    $fotoContent = addslashes(file_get_contents($foto));

    $id = $this->session->userdata('id');

    $gebruiker = new stdClass();
    $gebruiker->id = $id;
    $gebruiker->profileImage = $fotoContent;

    $this->load->model('gebruiker_model');
    $this->gebruiker_model->update($gebruiker);
    function update($gebruiker)
    {
        $this->db->where('id', $gebruiker->id);
        $this->db->update('gebruiker', $gebruiker);
    }
 <?php
    $attributes = array('name' => 'mijnFormulier', 'enctype'=>'multipart/form-data', 'method'=>'post', 'accept-charset'=>'utf-8');
    echo form_open('Home/wijzigen', $attributes);
    ?>
    <table>
        <tr>
            <td><?php echo form_label('Profiel Foto:', 'profielfoto'); ?></td>
            <td><input type="file" name="profielfoto" id="profielfoto" required accept=".png"/></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <?php echo form_submit('knop', 'Wijzigen', 'class = "btn btn-login login-formcontrol"'); ?>
            </td>
        </tr>


    </table>
    <?php echo form_close(); ?>
型号:

public function wijzigen()
{
    $foto = $this->input->post($_FILES['profielfoto']['tmp_name']);

    $fotoContent = addslashes(file_get_contents($foto));

    $id = $this->session->userdata('id');

    $gebruiker = new stdClass();
    $gebruiker->id = $id;
    $gebruiker->profileImage = $fotoContent;

    $this->load->model('gebruiker_model');
    $this->gebruiker_model->update($gebruiker);
    function update($gebruiker)
    {
        $this->db->where('id', $gebruiker->id);
        $this->db->update('gebruiker', $gebruiker);
    }
 <?php
    $attributes = array('name' => 'mijnFormulier', 'enctype'=>'multipart/form-data', 'method'=>'post', 'accept-charset'=>'utf-8');
    echo form_open('Home/wijzigen', $attributes);
    ?>
    <table>
        <tr>
            <td><?php echo form_label('Profiel Foto:', 'profielfoto'); ?></td>
            <td><input type="file" name="profielfoto" id="profielfoto" required accept=".png"/></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <?php echo form_submit('knop', 'Wijzigen', 'class = "btn btn-login login-formcontrol"'); ?>
            </td>
        </tr>


    </table>
    <?php echo form_close(); ?>
查看:

public function wijzigen()
{
    $foto = $this->input->post($_FILES['profielfoto']['tmp_name']);

    $fotoContent = addslashes(file_get_contents($foto));

    $id = $this->session->userdata('id');

    $gebruiker = new stdClass();
    $gebruiker->id = $id;
    $gebruiker->profileImage = $fotoContent;

    $this->load->model('gebruiker_model');
    $this->gebruiker_model->update($gebruiker);
    function update($gebruiker)
    {
        $this->db->where('id', $gebruiker->id);
        $this->db->update('gebruiker', $gebruiker);
    }
 <?php
    $attributes = array('name' => 'mijnFormulier', 'enctype'=>'multipart/form-data', 'method'=>'post', 'accept-charset'=>'utf-8');
    echo form_open('Home/wijzigen', $attributes);
    ?>
    <table>
        <tr>
            <td><?php echo form_label('Profiel Foto:', 'profielfoto'); ?></td>
            <td><input type="file" name="profielfoto" id="profielfoto" required accept=".png"/></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <?php echo form_submit('knop', 'Wijzigen', 'class = "btn btn-login login-formcontrol"'); ?>
            </td>
        </tr>


    </table>
    <?php echo form_close(); ?>

谢谢,

$\u文件和
$\u POST
变量是两种不同的东西

$foto = $this->input->post($_FILES['profielfoto']['tmp_name']);
应该是:

$foto = $_FILES['profielfoto']['tmp_name'];

请注意,这并没有考虑到错误,所以您应该理所当然地检查它。

$\u文件和
$\u POST
变量是两种不同的东西

$foto = $this->input->post($_FILES['profielfoto']['tmp_name']);
应该是:

$foto = $_FILES['profielfoto']['tmp_name'];

请注意,这并没有考虑到错误,因此您应该理所当然地检查它。

您的路由是否为此
主页/wijzigen
配置?请参阅您的路由是否为此
主页/wijzigen
配置?请参阅