不管我做什么,我都无法上传我的图片。下面是我的模型中的代码:
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);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
return $error;
}
else
{
$data = array('upload_data' => $this->upload->data());
return $data;
}
这是我控制器中的代码:
function do_upload()
{
$this->Upload_model->do_upload();
}
这是我的表格:
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo form_open_multipart('upload/do_upload');?>
<?php if(isset($buttons)) : foreach($buttons as $row) : ?>
<h2><?php echo $row->name; ?></h2>
<input type="file" name="userfile" size="20" />
<input type="hidden" name="oldfile" value="<?php echo $row->image_url; ?>" />
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<br /><br />
<label>Url: </label><input type="text" name="url" value="<?php echo $row->url; ?>" /><br /><br />
<input type="submit" value="submit" />
</form>
<?php endforeach; ?>
<?php endif; ?>
</body>
</html>
有人能告诉我我做错了什么吗?我是一个完全新手的代码点火器,它真的是让我在一个死胡同。除此之外,我希望能够将文件的路径写到我的数据库中,但我也无法找出答案,所以如果有人有答案,甚至是给我指出正确的方向,我将不胜感激。
谢谢
编辑-------
我上传的图片太高/太宽。但如果有人能告诉我如何将文件路径写入数据库,那就太好了!