Php $\u文件在CodeIgniter中为空
我正在使用CodeIgniter开发一个表单。在此字段中,其中一个字段是上载文件。我成功地学习了一些关于在CodeIgniter中上传文件的教程,但是在我的工作中,$\u文件总是空的,我不明白为什么。我是这个框架的新手 观点:Php $\u文件在CodeIgniter中为空,php,file,codeigniter,Php,File,Codeigniter,我正在使用CodeIgniter开发一个表单。在此字段中,其中一个字段是上载文件。我成功地学习了一些关于在CodeIgniter中上传文件的教程,但是在我的工作中,$\u文件总是空的,我不明白为什么。我是这个框架的新手 观点: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$this->load->helper('form');
echo form_open_multipart($action); ?>
Área:
<select>
<option value="1">Teste 1</option>
<option value="2">Teste 2</option>
</select> <br>
Data de abertura: <input type="text" id="data_abertura" placeholder="tqv"> <br>
Prioridade:<br>
<input type="radio" name="prioridade" value="3">Alta<br>
<input type="radio" name="prioridade" value="2">Média<br>
<input type="radio" name="prioridade" value="1">Baixa<br>
Anexar arquivo: <input type="file" accept="image/*, text/*, .doc, .docx, .pdf" name="arquivo" id="arquivo"><br>
Descrição: <br><textarea rows="4" cols="50" id="descricao" name="descricao"></textarea><br>
<input type="submit" id="enviar" name="enviar" value="Enviar">
<?php echo form_close() ?>
</body>
</html>
Área:
睾丸1
睾丸2
数据失真:
优先级:
Alta
梅迪亚
白沙
阿内克斯·阿奎沃:
描述:
控制员:
您是否在config/mimes.php文件中正确配置了所有扩展mime类型(pdf、txt等)
如果缺少mime类型,您可以很容易地在google上找到正确的mime类型;) 我不知道确切的原因,但更改允许的类型解决了这个问题$配置['allowed_types']='*';我正在测试一些txt和png文件。好了,现在没事了。对不起,这是个糟糕的问题。我不知道确切原因,但更改允许的类型解决了问题。>$配置['allowed_types']='*';我正在测试一些txt和png文件。好了,现在没事了。
<?php
class c_Formulario extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url');
}
public function index()
{
$data['action'] = site_url('c_formulario/inserir_dados');
$this->load->view('v_formulario', $data);
}
public function inserir_dados()
{
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png|doc|docx|pdf|txt';
$config['max_size'] = '100';
$this->load->library('upload');
$this->upload->initialize($config);
var_dump($_FILES);
foreach($_FILES as $field => $file)
{
//var_dump($_FILES); die();
// No problems with the file
if($file['error'] == 0)
{
// So lets upload
if ($this->upload->do_upload($field))
{
$data = $this->upload->data();
echo $data['full_path'];
}
else
{
$errors = $this->upload->display_errors();
var_dump($errors);
}
}
}
$this->load->model('m_formulario', '', TRUE);
$area = array('id' => null, 'nome' => $this->input->post('area', TRUE));
$data = array('id' => null, 'dataabert' => $this->input->post('data_abertura', TRUE));
$prioridade = array('id' => null, 'nome_prioridade' => $this->input->post('prioridade', TRUE));
$arquivo = array('id' => null, 'urlarquivo' => $this->input->post('arquivo', TRUE));
$descricao = array('id' => null, 'descricao' => $this->input->post('descricao', TRUE));
$dados = array
(
'area' => $area,
'data' => $data,
'prioridade' => $prioridade,
'arquivo' => $arquivo,
'descricao' => $descricao
);
$this->m_formulario->inserir($dados);
}