dourong4031 2015-03-10 08:06
浏览 36
已采纳

php codeigniter上传文件错误

this is my controller function and below is my view file code pleas help to find out the error in my code

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends CI_Controller {

    function __construct(){
        parent::__construct();
    }


    function test(){
        if($this->input->post('submit')){
            $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'].'/assets/uploads/';
            $config['allowed_types'] = 'mp4';
             $this->load->library('upload',$config);

            if ( ! $this->upload->do_upload()){
                $error = array('error' => $this->upload->display_errors());
            }else{
                $data = array('upload_data' => $this->upload->data());
            }
        }   
        $this->load->view('upload/test');
    }

}
?>

and this is my view code->

<form action="" method="POST" enctype="multipart/form-data" >
    Select File To Upload:<br />
    <input type="file" name="userfile"  />
    <br /><br />
    <input type="submit" name="submit" value="Upload" class="btn btn-success" />
</form>

and i m getting errors are -> enter image description here

  • 写回答

1条回答 默认 最新

  • dongpao9437 2015-03-10 15:00
    关注

    Finally i got this working,it took whole day. I was developing this on CI version->3.0 and when i replace my system folder with the new updated CI VERSION->3.0rc2 it worked like a charm in a single go and didn't change a single line in the above code.Both are development version of CI-3.But in the updated version my form validation stopped working, but as in the last version it was working fine so i copied my old version system/library/form_validation.php to new version at the same place and it is working fine now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀