|
php代码
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
function index()
{ echo $config['upload_path'] = base_url().'uploads/';
$this->load->view('upload_form');
}
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$this->upload->do_upload();
$data['data'] = $this->upload->data();
$this->load->view('upload_success', $data);
// $img = $this->upload->file_name;
$img=$data['data']['file_name'];
echo $img;
}
}
?>
html
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<h3>Your file was successfully uploaded!</h3>
<ul>
<?php foreach ($data as $item => $value):?>
<li><?php echo $item;?>: <?php echo $value;?></li>
<?php endforeach; ?>
</ul>
<p><?php echo anchor('upload', 'Upload Another File!'); ?></p>
</body>
</html>
html
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo "ceshi " ?>;
<form id="upup" action="do_upload" method="post" enctype="multipart/form-data">
<input type="file" name="userfile" size="20" />
<input type="submit" value="提交" />
</form>
</body>
</html>
请问 为什么文件家里没有图片
|
|