这是我的查看页面表单HTML代码:
welcome_message.php
<div class="form-group">
<input type="file" name="profile_name" >
</div>
的welcome.php
public function do_upload() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'doc|xml|docx|PDF|DOC|XML|DOCX|xls|xlsx';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this - > load - > library('Welcome', $config);
if (!$this - > Welcome - > do_upload('profile_name')) {
$error = array('error' => $this - > upload - > display_errors());
$this - > load - > view('welcome_message', $error);
} else {
$data = array(
'upload_data' => $this - > upload - > data()
);
$this - > load - > view('upload_success', $data);
//echo "Your file was successfully uploaded!";
}
}
这是成功的功能代码:upload_success.php
<body>
<h3>Your file was successfully uploaded!</h3>
<ul>
<?php foreach ($upload_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>
答案 0 :(得分:0)
$this->load->library('Welcome', $config);
$this->upload->initialize($config);
检查这是否对您有所帮助,在加载库后初始化上传配置。