0
任何人都可以幫助我嗎? 當我嘗試使用CodeIgniter的文件上傳類上傳圖像當試圖上傳圖像本地主機http錯誤500 codeigniter
http://www.codeigniter.com/user_guide/libraries/file_uploading.html?highlight=file%20upload
只是喜歡,但我總是會遇到這樣的錯誤 localhost http 500 error
請人幫我。
這是我的控制器
class Upload extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function index()
{
$this->load->view('upload_view', array('error' => ' '));
}
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if (! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_view', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}}
這是我的看法upload_view.php
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo $error;?>
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="userfile" size="20" />
<input type="submit" value="upload" />
<?php form_close(); ?>
</body>
</html>
和upload_success.php
<html>
<head>
<title> Image Upload </title>
</head>
<body>
<div id="container">
<dl>
<dt>
File Name:
</dt>
<dd>
<?php echo $uploadInfo['file_name'];?>
</dd>
<dt>
File Size:
</dt>
<dd>
<?php echo $uploadInfo['file_size'];?>
</dd>
<dt>
File Extension:
</dt>
<dd>
<?php echo $uploadInfo['file_ext'];?>
</dd>
<br />
<p>The Image:</p>
<img alt="uploaded image" src="<?=base_url(). 'uploads/' . $uploadInfo['file_name'];?>">
</dl>
</div>
</body>
</html>
已經這樣做了,但你仍然認爲錯誤頁面[:: 1]不起作用 – Ndragoonz
上傳你的代碼在這裏.. – Gulshan
你可以看看我編輯的問題。 @gulshan – Ndragoonz