我有问题,我的orig_name文件上传是在数据库上成功上传,但文件没有上传到我的文件夹..
这是我的控制器代码
public function insert(){
$this->model->register();
$this->run_upload();
redirect('Controling/daftar');
}
public function run_upload(){
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = '100000';
$config['max_width'] = '3024';
$config['max_heigth'] = '2024';
$this->load->library('upload', $config);
$data = array('upload_data' => $this->upload->data());
$datafoto=$this->upload->data();
$nm_file = time().$datafoto['orig_name'];
$this->load->model('model');
$this->model->update_file($nm_file);
copy('upload/'.$datafoto['orig_name'], 'upload/'.$nm_file);
}
这是我的观点代码
<?php echo form_open_multipart('Controling/insert', 'form="form"')?>
<h2 class="">Register</h2>
<label>Nim</label><input type="text" name="nim" class="form-control"><br />
<label>Username</label><input type="text" name="username" class="form-control"><br />
<label>Password</label><input type="password" name="password" class="form-control"><br />
<label>Masukkan File</label>
<input type="file" name="userfile" size="20" class="form-control"><br />
<input class="btn btn-primary" type="submit" name="register" value="Daftar">
<?php echo form_close(); ?>
答案 0 :(得分:0)
在config / mimes.php中添加你要上传的丢失文件类型,类似于贝娄。
'mpeg' => array('video/mpeg', 'video/quicktime'),
'mpg' => array('video/mpeg', 'video/quicktime'),
'mp4' => array('video/mp4', 'video/quicktime'),
'mpe' => array('video/mpeg', 'video/quicktime'),
'qt' => 'video/quicktime',
'mov' => array('video/quicktime', 'video/mp4'),
'avi' => array('video/avi', 'video/x-msvideo'),