您没有选择要上传的文件.PHP 代码点火器 [英] You did not select a file to upload. PHP Code Igniter

查看:20
本文介绍了您没有选择要上传的文件.PHP 代码点火器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现发布功能,并希望从 php 视图中选择消息和图像.我的消息功能运行良好.但是在上传图片时,我收到一个错误您没有选择要上传的文件.这是我的控制器功能

函数 post_func(){session_start();echo $post_message=$_POST['post'];echo $share_with=$_POST['share_with'];echo $image=$_POST['image'];如果($图像==空){echo "<br/>没有图像<br/>";}别的{////////////////////////////////////////////////////////////////////////////////////////$config['upload_path'] = './application/css';$config['allowed_types'] = 'gif|jpg|png';$config['max_size'] = '100';$config['max_width'] = '1024';$config['max_height'] = '768';$this->load->library('upload', $config);$this->upload->initialize($config);如果 ( !$this->upload->do_upload()){$error = array('error' => $this->upload->display_errors());回声<br/>";echo $this->upload->display_errors();echo "<br/> 图像错误<br/>";}别的{echo "<br/> 到达 <br/>";session_start();$this->membership_model->insert_images($this->upload->data(),$email);$data = array('upload_data' => $this->upload->data());echo "<br/问题<br/>";}////////////////////////////////////////////////////////////////////////////////////////}$公共;if($share_with=="public"){回声1";$公共=真;}别的{回声0";$公共=假;}echo "-----------------------------<br/>";echo $user=$this->session->userdata('user_identification');$数据 = 数组('用户名'=>$用户,'公共' =>$公众,'消息' =>$post_message,'图片名' =>没有任何");$this->load->model('membership_model');$this->membership_model->add_message($data);回声</br>";echo $user=$this->session->userdata('user_identification');}

这是我的看法.

<textarea name="post" rows="5" cols="30" placeholder="Share an update..." id="post_text" rows="2" value=""></textarea>//其他视图项<?phpecho form_close();?>

请帮帮我

解决方案

更改:

I am trying to implement a post functionality and want to pick message and image from a php view. My message functionality is working good. But on image upload i receive an error You did not select a file to upload. This is my controller function

function post_func()
{
    session_start();
    echo $post_message=$_POST['post'];
    echo $share_with=$_POST['share_with'];
    echo $image=$_POST['image'];
    if($image==null){
        echo "<br/>no image<br/>";  
    }
    else{
        ////////////////////////////////////////////////////////////////////////////////////////

            $config['upload_path'] = './application/css';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size'] = '100';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';


            $this->load->library('upload', $config);


            $this->upload->initialize($config);



            if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());

                echo "<br/>";
                echo $this->upload->display_errors();
                echo "<br/> image error<br/>";
            }
            else
            {

                echo "<br/> reached <br/>";
                session_start();
                $this->membership_model->insert_images($this->upload->data(),$email);
                $data = array('upload_data' => $this->upload->data());

                echo "<br/ problem<br/>";
            }




        ////////////////////////////////////////////////////////////////////////////////////////
    }
    $public;
    if($share_with=="public"){
        echo "1";
        $public=true;
    }else{
        echo "0";
        $public=false;
    }echo "-----------------------------<br/>";
    echo $user=$this->session->userdata('user_identification');
    $data = array 
            (
                'userid'=> $user,
                'public' => $public,
                'message' => $post_message,
                'picname' => "None"
            );
    $this->load->model('membership_model');
    $this->membership_model->add_message($data);
    echo "</br>";
    echo $user=$this->session->userdata('user_identification');
}

This is my view.

<?php echo form_open('search/post_func');?>

<!--<form id="loginForm" action="../search/post_func" method="post" enctype="multipart/form-data" >-->
<div id="your_post">
<div id="post_image">
<img   id ="post_img" src="<?php  echo $this->config->item('base_url'); ?><?php echo '/application/css/'. $img ?>"/>
</div>
<textarea name="post" rows="5" cols="30" placeholder="Share an update..." id="post_text" rows="2" value=""></textarea>

//other view items
            <?php
    echo form_close();
    ?> 

Please help me

解决方案

Change:

<?php echo form_open_multipart('search/post_func');?>

这篇关于您没有选择要上传的文件.PHP 代码点火器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆