|
本帖最后由 fed 于 2014-12-8 11:20 编辑
在试上传类,选好图片后,点击上传,index.php/upload...变成了 index.php?upload... 什么原因?
PHP复制代码
<?php
class Upload extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper(array('form','url'));
}
public function index()
{
$this->load->view('upload_form',array('error'=>''));
}
public function do_upload()
{
$config['upload_path'] ='./uploads/';
$config['allowd_types'] ='gif|jpg|png';
$config['max_size'] ='100';
$config['max_width'] ='1024';
$config['max_height'] ='768';
$this->load->library('upload',$config);
if(! $this->upload->do_upload())
{
$error = array('error'=>$this->upload->display_errors());
$this->load->view('upload_form',$error);
}
else
{
$data = array('upload_data'=>$this->upload->data());
$this->load->view('upload_success',$data);
}
}
}[/color][color=#333333]?>
复制代码
PHP复制代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>upload</title>
</head>
<body>
<?php echo $error; ?>
<?php echo form_open_multipart('upload/do_upload'); ?>
<input type="file" name="userfile" size="20"/>
<br/>
<input type="submit" value="上传"/>
</form>
</body>
</html>
复制代码
|
|