2012-08-13 42 views
0

希望有人可以幫助我解決這個問題。使用CI創建多個文件上載表單

我正在開發一個允許使用CodeIgniter和jQuery上傳多個文件以允許使用一個uploadfield上傳多個文件的表單。

但現在我得到以下ERRMSG在Firebug:

HTML文檔的字符編碼未聲明。如果文檔包含US-ASCII範圍之外的字符,則該文檔將在某些瀏覽器配置中呈現亂碼文本。頁面的字符編碼必須在文檔或傳輸協議中聲明。

這意味着HTML文檔不會被刪除,但我不明白髮生了什麼問題。

我有以下控制器:

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

class Upload extends CI_Controller { 


    function Upload(){ 

     parent::Controller(); 
     $this->load->helper(array('form', 'url')); 
    } 


    public function index(){ 

     $this->load->view('includes/header'); 
     $this->load->view('upload'); 
     $this->load->view('includes/footer'); 
    } 

    function do_upload() 
    { 
     $config['upload_path'] = './uploads/'; // server directory 
     $config['allowed_types'] = 'gif|jpg|png'; // by extension, will check for whether it is an image 
     $config['max_size'] = '1000'; // in kb 
     $config['max_width'] = '1024'; 
     $config['max_height'] = '768'; 

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

     $files = $this->multi_upload->go_upload(); 

     if (! $files)   
     { 
      $error = array('error' => $this->upload->display_errors()); 
      $this->load->view('upload_form', $error); 
     }  
     else 
     { 
      $data = array('upload_data' => $files); 
      $this->load->view('upload_success', $data); 
     } 
    } 
} 

所以,我首先想到的是我還沒有decleared元標記在頭但事實並非如此:

<head> 
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" > 
<link href="<?=base_url();?>src/css/style.css" rel="stylesheet" type="text/css"> 
<script src="http://code.jquery.com/jquery-1.8.0.js"></script> 
<script src="<?=base_url();?>src/js/jquery.MultiFile.js"></script>  
</head> 

如果我從控制器中刪除上傳功能我得到一個錯誤的調用未定義的方法form_open_multipart

所以我不知道爲什麼我得到errmsg我第一次表示。有人能幫助我嗎?

在此先感謝

+0

你能從發佈消息的頁面發佈源HTML嗎? – 2012-08-13 18:41:56

+0

生成HTML字符編碼消息的HTML頁面的源爲空... – PimD1988 2012-08-14 05:50:04

+0

這不是問題嗎?您正在加載一個空白頁面,Firebug會拋出它遇到的第一個錯誤。你確定你的視圖'upload_form'和'upload_success'包含正確的數據嗎? – 2012-08-14 11:58:48

回答

相關問題