我在codeigniter中发现了一些关于保存文件上传的问题,我已经从互联网上得到了一些建议,但是在我实施之后它没有起作用,让我们检查一下:
控制器:
cd /usr/local/apache-tomcat7/logs
tail -f Catalina.out
观点(Lampiran'表格):
function save_data()
{
$in['jenis'] = $this->input->post("jenis");
$in['judul'] = $this->input->post("judul");
$in['nomor'] = $this->input->post("nomor");
$in['tanggal'] = $this->input->post("tanggal");
$in['nilai'] = $this->input->post("nilai");
$in['deskripsi'] = $this->input->post("deskripsi");
$in['penerbit'] = $this->input->post("penerbit");
$acak=rand(00000000000,99999999999);
$bersih=$_FILES['userfile']['name'];
$nm=str_replace(" ","_","$bersih");
$pisah=explode(".",$nm);
$nama_murni=$pisah[0];
$ubah=$acak.$nama_murni; //tanpa ekstensi
$config["file_name"]=$ubah; //dengan eekstensi
$in["lampiran"]=$acak.$nm;
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'exe|sql|psd|pdf|xls|ppt|php|php4|php3|js|swf|Xhtml|zip|wav|bmp|gif|jpg|jpeg|png|html|htm|txt|rtf|mpeg|mpg|avi|doc|docx|xlsx';
$config['max_size'] = '50000';
$config['max_width'] = '1200';
$config['max_height'] = '1200';
$this->load->library('upload', $config);
if(!$this->upload->do_upload())
{
echo $this->upload->display_errors();
}
else {
$this->db->insert("tbl_pengadaan",$in);
?>
<script>
window.parent.location.reload(true);
</script>
<?php
}
}
在我运行上面的代码之后,它显示了这样的警告:
<label class="control-label" for="nama_hukuman">File Lampiran</label>
<div class="controls">
<input type="file" name="userfile">
</div>
文件附件无法上传,我想要的是上传文件后,文件名自动保存在数据库sql中的唯一编号,用于下载用户列表..
如果有任何建议,请, 感谢..