1
我是新來的。我已經搜索了關於上傳,但仍然沒有工作。爲什麼我的codeigniter上傳沒有運行
這是我的控制器功能
public function tambah() {
$this->data->error = '';
if($_POST){
$this->form_validation->set_rules($this->rules);
$config['upload_path'] = './uploads/berita/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '2048';
$config['max_width'] = '650';
$config['max_height'] = '270';
$config['encrypt_name'] = 'true';
$this->load->library('upload',$config);
if (! $this->upload->do_upload())
{
$this->data->error = $this->upload->display_errors();
}
else
{
$data = array('upload_data' => $this->upload->data());
}
}
}
,這是我的看法
<?php
if(@$error){echo @$error;}
echo validation_errors();
echo form_fieldset('Penambahan Berita','class="berita"');
echo '<div class="col-left">';
echo form_open_multipart(site_url(uri_string()));
echo form_label('Judul');
echo form_input('judul',@$judul,'class="input-text"');
echo form_label('Berita');
echo form_textarea('berita',@$berita,'style="width:300px;height:100px;"');
echo form_label('Url');
echo form_input('url',@$url,'class="input-text"');
echo form_label('Foto');
echo form_upload('pic');
echo form_submit('submit','Submit','class="input-submit"');
echo form_close();
echo '</div>';
echo form_fieldset_close();
?>
我不知道爲什麼,但是當我點擊提交有警告:
您沒有選擇要上傳的文件。
哇它的工作先生,非常感謝你,先生! – rudzstyle