Php 将文件上载到codeigniter控制器的表单上的空数据
我正在尝试使用此表单上载文件Php 将文件上载到codeigniter控制器的表单上的空数据,php,html,codeigniter,codeigniter-3,Php,Html,Codeigniter,Codeigniter 3,我正在尝试使用此表单上载文件 <form action="/ajax/images/store_image" method="post" enctype="multipart/form-data"> <div class="form-group"> <label for="exampleFormControlFile1">Selecciona una imagen</label> <i
<form action="/ajax/images/store_image" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleFormControlFile1">Selecciona una imagen</label>
<input type="file" class="form-control-file" id="exampleFormControlFile1">
<input type="hidden" name="{{ csrf_name }}" value="{{ csrf_hash }}">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
图像选择
提交
这是codeigniter控制器,用于监听请求
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/Common/Backend_Controller.php';
/**
* This class provides all the methods & functionallity of public "Batch operations" page.
*/
class Images extends Backend_Controller {
public function storeImage(){
var_dump($_POST);
}
}
您不能使用$\u POST
转储多部分表单数据。您必须使用$\u文件
NOTE: name attribute is missing from the file input. The name attribute is mandatory for submitting the form data.
转储$\u文件时会得到什么?您将name属性设置为input,然后使用$\u FILES['attribute\u name']['name']获取文件。您的文件输入字段缺少name属性。没有名称的表单字段不会成为表单提交数据集的一部分。