当试图上传图像本地主机http错误500 codeigniter
问题描述:
任何人都可以帮助我吗? 当我尝试使用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>
答
更改您的文件夹,文件权限和chmod -R 777文件夹名称
已经这样做了,但你仍然认为错误页面[:: 1]不起作用 – Ndragoonz
上传你的代码在这里.. – Gulshan
你可以看看我编辑的问题。 @gulshan – Ndragoonz